Minor refactorings and code style changes. 1) Removed several use of raw types 2) Removed unnecessary throws clauses 3) Used lambda expressions wherever applicable 4) Used apt assertion methods for readability 5) Use of try with resources wherever applicable 6) Corrected incorrect order of assertXXX arguments

This commit is contained in:
Narendra Pathai
2018-10-20 17:50:52 +05:30
parent 2f569d670a
commit 543eb9a4be
73 changed files with 207 additions and 298 deletions

View File

@ -41,6 +41,6 @@ public class CakeViewImpl implements View {
}
public void render() {
cakeBakingService.getAllCakes().stream().forEach(cake -> LOGGER.info(cake.toString()));
cakeBakingService.getAllCakes().forEach(cake -> LOGGER.info(cake.toString()));
}
}

View File

@ -35,14 +35,14 @@ import static org.junit.jupiter.api.Assertions.assertNull;
public class CakeBakingExceptionTest {
@Test
public void testConstructor() throws Exception {
public void testConstructor() {
final CakeBakingException exception = new CakeBakingException();
assertNull(exception.getMessage());
assertNull(exception.getCause());
}
@Test
public void testConstructorWithMessage() throws Exception {
public void testConstructorWithMessage() {
final String expectedMessage = "message";
final CakeBakingException exception = new CakeBakingException(expectedMessage);
assertEquals(expectedMessage, exception.getMessage());

View File

@ -42,7 +42,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class CakeBakingServiceImplTest {
@Test
public void testLayers() throws CakeBakingException {
public void testLayers() {
final CakeBakingServiceImpl service = new CakeBakingServiceImpl();
final List<CakeLayerInfo> initialLayers = service.getAvailableLayers();
@ -65,7 +65,7 @@ public class CakeBakingServiceImplTest {
}
@Test
public void testToppings() throws CakeBakingException {
public void testToppings() {
final CakeBakingServiceImpl service = new CakeBakingServiceImpl();
final List<CakeToppingInfo> initialToppings = service.getAvailableToppings();
@ -125,7 +125,7 @@ public class CakeBakingServiceImplTest {
}
@Test
public void testBakeCakeMissingTopping() throws CakeBakingException {
public void testBakeCakeMissingTopping() {
final CakeBakingServiceImpl service = new CakeBakingServiceImpl();
final CakeLayerInfo layer1 = new CakeLayerInfo("Layer1", 1000);
@ -140,7 +140,7 @@ public class CakeBakingServiceImplTest {
}
@Test
public void testBakeCakeMissingLayer() throws CakeBakingException {
public void testBakeCakeMissingLayer() {
final CakeBakingServiceImpl service = new CakeBakingServiceImpl();
final List<CakeInfo> initialCakes = service.getAllCakes();

View File

@ -44,7 +44,7 @@ public class CakeTest {
final Cake cake = new Cake();
assertNull(cake.getId());
final Long expectedId = Long.valueOf(1234L);
final Long expectedId = 1234L;
cake.setId(expectedId);
assertEquals(expectedId, cake.getId());
}