📍Use lombok, reformat, and optimize the code (#1560)
* Use lombok, reformat, and optimize the code * Fix merge conflicts and some sonar issues Co-authored-by: va1m <va1m@email.com>
This commit is contained in:
@ -82,10 +82,9 @@ public interface View {
|
||||
|
||||
}
|
||||
|
||||
@Slf4j
|
||||
public class CakeViewImpl implements View {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CakeViewImpl.class);
|
||||
|
||||
private final CakeBakingService cakeBakingService;
|
||||
|
||||
public CakeViewImpl(CakeBakingService cakeBakingService) {
|
||||
|
@ -24,16 +24,14 @@
|
||||
package com.iluwatar.layers.view;
|
||||
|
||||
import com.iluwatar.layers.service.CakeBakingService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* View implementation for displaying cakes.
|
||||
*/
|
||||
@Slf4j
|
||||
public class CakeViewImpl implements View {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CakeViewImpl.class);
|
||||
|
||||
private final CakeBakingService cakeBakingService;
|
||||
|
||||
public CakeViewImpl(CakeBakingService cakeBakingService) {
|
||||
|
@ -28,7 +28,7 @@ import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Application test
|
||||
*
|
||||
*/
|
||||
|
@ -23,19 +23,15 @@
|
||||
|
||||
package com.iluwatar.layers.entity;
|
||||
|
||||
import com.iluwatar.layers.entity.Cake;
|
||||
import com.iluwatar.layers.entity.CakeLayer;
|
||||
import com.iluwatar.layers.entity.CakeTopping;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Date: 12/15/15 - 8:02 PM
|
||||
*
|
||||
@ -44,7 +40,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
public class CakeTest {
|
||||
|
||||
@Test
|
||||
public void testSetId() {
|
||||
void testSetId() {
|
||||
final var cake = new Cake();
|
||||
assertNull(cake.getId());
|
||||
|
||||
@ -54,7 +50,7 @@ public class CakeTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetTopping() {
|
||||
void testSetTopping() {
|
||||
final var cake = new Cake();
|
||||
assertNull(cake.getTopping());
|
||||
|
||||
@ -64,21 +60,21 @@ public class CakeTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetLayers() {
|
||||
void testSetLayers() {
|
||||
final var cake = new Cake();
|
||||
assertNotNull(cake.getLayers());
|
||||
assertTrue(cake.getLayers().isEmpty());
|
||||
|
||||
final var expectedLayers = Set.of(
|
||||
new CakeLayer("layer1", 1000),
|
||||
new CakeLayer("layer2", 2000),
|
||||
new CakeLayer("layer3", 3000));
|
||||
new CakeLayer("layer1", 1000),
|
||||
new CakeLayer("layer2", 2000),
|
||||
new CakeLayer("layer3", 3000));
|
||||
cake.setLayers(expectedLayers);
|
||||
assertEquals(expectedLayers, cake.getLayers());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddLayer() {
|
||||
void testAddLayer() {
|
||||
final var cake = new Cake();
|
||||
assertNotNull(cake.getLayers());
|
||||
assertTrue(cake.getLayers().isEmpty());
|
||||
@ -101,7 +97,7 @@ public class CakeTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
void testToString() {
|
||||
final var topping = new CakeTopping("topping", 20);
|
||||
topping.setId(2345L);
|
||||
|
||||
@ -114,7 +110,7 @@ public class CakeTest {
|
||||
cake.addLayer(layer);
|
||||
|
||||
final var expected = "id=1234 topping=id=2345 name=topping calories=20 "
|
||||
+ "layers=[id=3456 name=layer calories=100]";
|
||||
+ "layers=[id=3456 name=layer calories=100]";
|
||||
assertEquals(expected, cake.toString());
|
||||
|
||||
}
|
||||
|
@ -23,12 +23,11 @@
|
||||
|
||||
package com.iluwatar.layers.exception;
|
||||
|
||||
import com.iluwatar.layers.exception.CakeBakingException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Date: 12/15/15 - 7:57 PM
|
||||
*
|
||||
@ -37,14 +36,14 @@ import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
public class CakeBakingExceptionTest {
|
||||
|
||||
@Test
|
||||
public void testConstructor() {
|
||||
void testConstructor() {
|
||||
final var exception = new CakeBakingException();
|
||||
assertNull(exception.getMessage());
|
||||
assertNull(exception.getCause());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstructorWithMessage() {
|
||||
void testConstructorWithMessage() {
|
||||
final var expectedMessage = "message";
|
||||
final var exception = new CakeBakingException(expectedMessage);
|
||||
assertEquals(expectedMessage, exception.getMessage());
|
||||
|
@ -23,17 +23,19 @@
|
||||
|
||||
package com.iluwatar.layers.service;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import com.iluwatar.layers.dto.CakeInfo;
|
||||
import com.iluwatar.layers.dto.CakeLayerInfo;
|
||||
import com.iluwatar.layers.dto.CakeToppingInfo;
|
||||
import com.iluwatar.layers.exception.CakeBakingException;
|
||||
import com.iluwatar.layers.service.CakeBakingServiceImpl;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Date: 12/15/15 - 9:55 PM
|
||||
@ -43,7 +45,7 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||
public class CakeBakingServiceImplTest {
|
||||
|
||||
@Test
|
||||
public void testLayers() {
|
||||
void testLayers() {
|
||||
final var service = new CakeBakingServiceImpl();
|
||||
|
||||
final var initialLayers = service.getAvailableLayers();
|
||||
@ -66,7 +68,7 @@ public class CakeBakingServiceImplTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToppings() {
|
||||
void testToppings() {
|
||||
final var service = new CakeBakingServiceImpl();
|
||||
|
||||
final var initialToppings = service.getAvailableToppings();
|
||||
@ -89,7 +91,7 @@ public class CakeBakingServiceImplTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBakeCakes() throws CakeBakingException {
|
||||
void testBakeCakes() throws CakeBakingException {
|
||||
final var service = new CakeBakingServiceImpl();
|
||||
|
||||
final var initialCakes = service.getAllCakes();
|
||||
@ -126,7 +128,7 @@ public class CakeBakingServiceImplTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBakeCakeMissingTopping() {
|
||||
void testBakeCakeMissingTopping() {
|
||||
final var service = new CakeBakingServiceImpl();
|
||||
|
||||
final var layer1 = new CakeLayerInfo("Layer1", 1000);
|
||||
@ -141,7 +143,7 @@ public class CakeBakingServiceImplTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBakeCakeMissingLayer() {
|
||||
void testBakeCakeMissingLayer() {
|
||||
final var service = new CakeBakingServiceImpl();
|
||||
|
||||
final var initialCakes = service.getAllCakes();
|
||||
@ -161,7 +163,7 @@ public class CakeBakingServiceImplTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBakeCakesUsedLayer() throws CakeBakingException {
|
||||
void testBakeCakesUsedLayer() throws CakeBakingException {
|
||||
final var service = new CakeBakingServiceImpl();
|
||||
|
||||
final var initialCakes = service.getAllCakes();
|
||||
|
@ -23,6 +23,10 @@
|
||||
|
||||
package com.iluwatar.layers.view;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import ch.qos.logback.classic.Logger;
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||
import ch.qos.logback.core.AppenderBase;
|
||||
@ -30,19 +34,13 @@ import com.iluwatar.layers.dto.CakeInfo;
|
||||
import com.iluwatar.layers.dto.CakeLayerInfo;
|
||||
import com.iluwatar.layers.dto.CakeToppingInfo;
|
||||
import com.iluwatar.layers.service.CakeBakingService;
|
||||
import com.iluwatar.layers.view.CakeViewImpl;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* Date: 12/15/15 - 10:04 PM
|
||||
*
|
||||
@ -66,12 +64,12 @@ public class CakeViewImplTest {
|
||||
* Verify if the cake view renders the expected result
|
||||
*/
|
||||
@Test
|
||||
public void testRender() {
|
||||
void testRender() {
|
||||
|
||||
final var layers = List.of(
|
||||
new CakeLayerInfo("layer1", 1000),
|
||||
new CakeLayerInfo("layer2", 2000),
|
||||
new CakeLayerInfo("layer3", 3000));
|
||||
new CakeLayerInfo("layer1", 1000),
|
||||
new CakeLayerInfo("layer2", 2000),
|
||||
new CakeLayerInfo("layer3", 3000));
|
||||
|
||||
final var cake = new CakeInfo(new CakeToppingInfo("topping", 1000), layers);
|
||||
final var cakes = List.of(cake);
|
||||
|
Reference in New Issue
Block a user