[JAVA-14174] Renamed paterns to paterns-module (#12718)
* [JAVA-14174] Renamed paterns to paterns-module * [JAVA-14174] naming fixes Co-authored-by: panagiotiskakos <panagiotis.kakos@libra-is.com>
This commit is contained in:
+37
@@ -0,0 +1,37 @@
|
||||
package com.baeldung.chainofresponsibility;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class ChainOfResponsibilityIntegrationTest {
|
||||
|
||||
private static AuthenticationProcessor getChainOfAuthProcessor() {
|
||||
|
||||
AuthenticationProcessor oAuthProcessor = new OAuthAuthenticationProcessor(null);
|
||||
AuthenticationProcessor unamePasswordProcessor = new UsernamePasswordAuthenticationProcessor(oAuthProcessor);
|
||||
return unamePasswordProcessor;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenOAuthProvider_whenCheckingAuthorized_thenSuccess() {
|
||||
AuthenticationProcessor authProcessorChain = getChainOfAuthProcessor();
|
||||
boolean isAuthorized = authProcessorChain.isAuthorized(new OAuthTokenProvider());
|
||||
assertTrue(isAuthorized);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenUsernamePasswordProvider_whenCheckingAuthorized_thenSuccess() {
|
||||
AuthenticationProcessor authProcessorChain = getChainOfAuthProcessor();
|
||||
boolean isAuthorized = authProcessorChain.isAuthorized(new UsernamePasswordProvider());
|
||||
assertTrue(isAuthorized);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenSamlAuthProvider_whenCheckingAuthorized_thenFailure() {
|
||||
AuthenticationProcessor authProcessorChain = getChainOfAuthProcessor();
|
||||
boolean isAuthorized = authProcessorChain.isAuthorized(new SamlAuthenticationProvider());
|
||||
assertTrue(!isAuthorized);
|
||||
}
|
||||
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.baeldung.command.test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.baeldung.command.command.OpenTextFileOperation;
|
||||
import com.baeldung.command.command.TextFileOperation;
|
||||
import com.baeldung.command.receiver.TextFile;
|
||||
|
||||
public class OpenTextFileOperationUnitTest {
|
||||
|
||||
@Test
|
||||
public void givenOpenTextFileOperationIntance_whenCalledExecuteMethod_thenOneAssertion() {
|
||||
TextFileOperation openTextFileOperation = new OpenTextFileOperation(new TextFile("file1.txt"));
|
||||
assertThat(openTextFileOperation.execute()).isEqualTo("Opening file file1.txt");
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.baeldung.command.test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.baeldung.command.command.SaveTextFileOperation;
|
||||
import com.baeldung.command.command.TextFileOperation;
|
||||
import com.baeldung.command.receiver.TextFile;
|
||||
|
||||
public class SaveTextFileOperationUnitTest {
|
||||
|
||||
@Test
|
||||
public void givenSaveTextFileOperationIntance_whenCalledExecuteMethod_thenOneAssertion() {
|
||||
TextFileOperation openTextFileOperation = new SaveTextFileOperation(new TextFile("file1.txt"));
|
||||
assertThat(openTextFileOperation.execute()).isEqualTo("Saving file file1.txt");
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
package com.baeldung.command.test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.baeldung.command.command.OpenTextFileOperation;
|
||||
import com.baeldung.command.command.SaveTextFileOperation;
|
||||
import com.baeldung.command.command.TextFileOperation;
|
||||
import com.baeldung.command.invoker.TextFileOperationExecutor;
|
||||
import com.baeldung.command.receiver.TextFile;
|
||||
|
||||
public class TextFileOperationExecutorUnitTest {
|
||||
|
||||
private static TextFileOperationExecutor textFileOperationExecutor;
|
||||
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpTextFileOperationExecutor() {
|
||||
textFileOperationExecutor = new TextFileOperationExecutor();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenTextFileOPerationExecutorInstance_whenCalledexecuteOperationWithOpenTextOperation_thenOneAssertion() {
|
||||
TextFileOperation textFileOperation = new OpenTextFileOperation(new TextFile("file1.txt"));
|
||||
assertThat(textFileOperationExecutor.executeOperation(textFileOperation)).isEqualTo("Opening file file1.txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenTextFileOPerationExecutorInstance_whenCalledexecuteOperationWithSaveTextOperation_thenOneAssertion() {
|
||||
TextFileOperation textFileOperation = new SaveTextFileOperation(new TextFile("file1.txt"));
|
||||
assertThat(textFileOperationExecutor.executeOperation(textFileOperation)).isEqualTo("Saving file file1.txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenTextFileOperationExecutorInstance_whenCalledexecuteOperationWithTextFileOpenLambda_thenOneAssertion() {
|
||||
assertThat(textFileOperationExecutor.executeOperation(() -> {return "Opening file file1.txt";})).isEqualTo("Opening file file1.txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenTextFileOperationExecutorInstance_whenCalledexecuteOperationWithTextFileSaveLambda_thenOneAssertion() {
|
||||
assertThat(textFileOperationExecutor.executeOperation(() -> {return "Saving file file1.txt";})).isEqualTo("Saving file file1.txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenTextFileOperationExecutorInstance_whenCalledexecuteOperationWithTextFileOpenMethodReferenceOfExistingObject_thenOneAssertion() {
|
||||
TextFile textFile = new TextFile("file1.txt");
|
||||
assertThat(textFileOperationExecutor.executeOperation(textFile::open)).isEqualTo("Opening file file1.txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenTextFileOperationExecutorInstance_whenCalledexecuteOperationWithTextFileSaveMethodReferenceOfExistingObject_thenOneAssertion() {
|
||||
TextFile textFile = new TextFile("file1.txt");
|
||||
assertThat(textFileOperationExecutor.executeOperation(textFile::save)).isEqualTo("Saving file file1.txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenOpenTextFileOperationExecuteMethodReference_whenCalledApplyMethod_thenOneAssertion() {
|
||||
Function<OpenTextFileOperation, String> executeMethodReference = OpenTextFileOperation::execute;
|
||||
assertThat(executeMethodReference.apply(new OpenTextFileOperation(new TextFile("file1.txt")))).isEqualTo("Opening file file1.txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenSaveTextFileOperationExecuteMethodReference_whenCalledApplyMethod_thenOneAssertion() {
|
||||
Function<SaveTextFileOperation, String> executeMethodReference = SaveTextFileOperation::execute;
|
||||
assertThat(executeMethodReference.apply(new SaveTextFileOperation(new TextFile("file1.txt")))).isEqualTo("Saving file file1.txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenOpenAndSaveTextFileOperationExecutorInstance_whenCalledExecuteOperationWithLambdaExpression_thenBothAssertion() {
|
||||
TextFileOperationExecutor textFileOperationExecutor = new TextFileOperationExecutor();
|
||||
assertThat(textFileOperationExecutor.executeOperation(() -> "Opening file file1.txt")).isEqualTo("Opening file file1.txt");
|
||||
assertThat(textFileOperationExecutor.executeOperation(() -> "Saving file file1.txt")).isEqualTo("Saving file file1.txt");
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.baeldung.command.test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.baeldung.command.receiver.TextFile;
|
||||
|
||||
public class TextFileUnitTest {
|
||||
|
||||
private static TextFile textFile;
|
||||
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpTextFileInstance() {
|
||||
textFile = new TextFile("file1.txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenTextFileInstance_whenCalledopenMethod_thenOneAssertion() {
|
||||
assertThat(textFile.open()).isEqualTo("Opening file file1.txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenTextFileInstance_whenCalledwriteMethod_thenOneAssertion() {
|
||||
assertThat(textFile.write()).isEqualTo("Writing to file file1.txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenTextFileInstance_whenCalledsaveMethod_thenOneAssertion() {
|
||||
assertThat(textFile.save()).isEqualTo("Saving file file1.txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenTextFileInstance_whenCalledcopyMethod_thenOneAssertion() {
|
||||
assertThat(textFile.copy()).isEqualTo("Copying file file1.txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenTextFileInstance_whenCalledpasteMethod_thenOneAssertion() {
|
||||
assertThat(textFile.paste()).isEqualTo("Pasting file file1.txt");
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.baeldung.mediator;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class MediatorIntegrationTest {
|
||||
|
||||
private Button button;
|
||||
private Fan fan;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
this.button = new Button();
|
||||
this.fan = new Fan();
|
||||
PowerSupplier powerSupplier = new PowerSupplier();
|
||||
Mediator mediator = new Mediator();
|
||||
|
||||
mediator.setButton(this.button);
|
||||
mediator.setFan(fan);
|
||||
mediator.setPowerSupplier(powerSupplier);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenTurnedOffFan_whenPressingButtonTwice_fanShouldTurnOnAndOff() {
|
||||
assertFalse(fan.isOn());
|
||||
|
||||
button.press();
|
||||
assertTrue(fan.isOn());
|
||||
|
||||
button.press();
|
||||
assertFalse(fan.isOn());
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.baeldung.nulls;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
class PrimitivesAndWrapperUnitTest {
|
||||
|
||||
@Test
|
||||
public void givenBothArgsNonNull_whenCallingWrapperSum_thenReturnSum() {
|
||||
|
||||
Integer sum = PrimitivesAndWrapper.wrapperSum(0, 0);
|
||||
|
||||
assertEquals(0, sum.intValue());
|
||||
}
|
||||
|
||||
@Test()
|
||||
public void givenOneArgIsNull_whenCallingWrapperSum_thenThrowNullPointerException() {
|
||||
assertThrows(NullPointerException.class, () -> PrimitivesAndWrapper.wrapperSum(null, 2));
|
||||
}
|
||||
|
||||
@Test()
|
||||
public void givenBothArgsNull_whenCallingWrapperSum_thenThrowNullPointerException() {
|
||||
assertThrows(NullPointerException.class, () -> PrimitivesAndWrapper.wrapperSum(null, null));
|
||||
}
|
||||
|
||||
@Test()
|
||||
public void givenOneArgNull_whenCallingGoodSum_thenThrowIllegalArgumentException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> PrimitivesAndWrapper.goodSum(null, 2));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.baeldung.nulls;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
class UsingLombokUnitTest {
|
||||
|
||||
private UsingLombok classUnderTest;
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
classUnderTest = new UsingLombok();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenNullArg_thenThrowNullPointerException() {
|
||||
|
||||
assertThrows(NullPointerException.class, () -> classUnderTest.accept(null));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.baeldung.nulls;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
class UsingObjectsUnitTest {
|
||||
|
||||
private UsingObjects classUnderTest;
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
classUnderTest = new UsingObjects();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenArgIsNull_thenThrowException() {
|
||||
|
||||
assertThrows(NullPointerException.class, () -> classUnderTest.accept(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenArgIsNonNull_thenDoesNotThrowException() {
|
||||
|
||||
assertDoesNotThrow(() -> classUnderTest.accept("test "));
|
||||
}
|
||||
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
package com.baeldung.nulls;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class UsingOptionalUnitTest {
|
||||
|
||||
private UsingOptional dataObject;
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
dataObject = new UsingOptional();
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenArgIsFalse_thenReturnEmptyResponse() {
|
||||
Optional<Object> result = dataObject.process(false);
|
||||
|
||||
assertFalse(result.isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenArgIsTrue_thenReturnValidResponse() {
|
||||
Optional<Object> result = dataObject.process(true);
|
||||
|
||||
assertTrue(result.isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenArgIsFalse_thenChainResponseAndThrowException() {
|
||||
assertThrows(Exception.class, () -> dataObject.process(false).orElseThrow(Exception::new));
|
||||
}
|
||||
|
||||
@Test()
|
||||
void givenEmptyList_whenFindFirst_getDefaultValue() {
|
||||
assertTrue(dataObject.findFirst().equalsIgnoreCase(UsingOptional.DEFAULT_VALUE));
|
||||
}
|
||||
|
||||
@Test()
|
||||
void givenEmptyList_whenFindOptionalFirst_returnsEmptyOptional() {
|
||||
assertFalse(dataObject.findOptionalFirst().isPresent());
|
||||
}
|
||||
|
||||
@Test()
|
||||
void whenOptionalListFirst_returnsEmptyOptional() {
|
||||
assertFalse(dataObject.optionalListFirst().isPresent());
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package com.baeldung.nulls;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
class UsingStringUtilsUnitTest {
|
||||
|
||||
private UsingStringUtils classUnderTest;
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
classUnderTest = new UsingStringUtils();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenArgIsNull_whenCallingAccept_throwIllegalArgumentException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> classUnderTest.accept(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenArgIsEmpty_whenCallingAccept_throwIllegalArgumentException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> classUnderTest.accept(""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenArgIsNull_whenCallingAcceptOnlyNonBlank_throwIllegalArgumentException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> classUnderTest.acceptOnlyNonBlank(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenArgIsEmpty_whenCallingAcceptOnlyNonBlank_throwIllegalArgumentException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> classUnderTest.acceptOnlyNonBlank(""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenArgIsBlank_whenCallingAcceptOnlyNonBlank_throwIllegalArgumentException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> classUnderTest.acceptOnlyNonBlank(" "));
|
||||
}
|
||||
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package com.baeldung.observer;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.baeldung.observer.NewsAgency;
|
||||
import com.baeldung.observer.NewsChannel;
|
||||
|
||||
public class ObserverIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void whenChangingNewsAgencyState_thenNewsChannelNotified() {
|
||||
|
||||
NewsAgency observable = new NewsAgency();
|
||||
NewsChannel observer = new NewsChannel();
|
||||
|
||||
observable.addObserver(observer);
|
||||
|
||||
observable.setNews("news");
|
||||
assertEquals(observer.getNews(), "news");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenChangingONewsAgencyState_thenONewsChannelNotified() {
|
||||
|
||||
ONewsAgency observable = new ONewsAgency();
|
||||
ONewsChannel observer = new ONewsChannel();
|
||||
|
||||
observable.addObserver(observer);
|
||||
|
||||
observable.setNews("news");
|
||||
assertEquals(observer.getNews(), "news");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenChangingPCLNewsAgencyState_thenONewsChannelNotified() {
|
||||
|
||||
PCLNewsAgency observable = new PCLNewsAgency();
|
||||
PCLNewsChannel observer = new PCLNewsChannel();
|
||||
|
||||
observable.addPropertyChangeListener(observer);
|
||||
|
||||
observable.setNews("news");
|
||||
assertEquals(observer.getNews(), "news");
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.baeldung.state;
|
||||
|
||||
import com.baeldung.state.Package;
|
||||
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class StatePatternUnitTest {
|
||||
|
||||
@Test
|
||||
public void givenNewPackage_whenPackageReceived_thenStateReceived() {
|
||||
Package pkg = new Package();
|
||||
|
||||
assertThat(pkg.getState(), instanceOf(OrderedState.class));
|
||||
pkg.nextState();
|
||||
|
||||
assertThat(pkg.getState(), instanceOf(DeliveredState.class));
|
||||
pkg.nextState();
|
||||
|
||||
assertThat(pkg.getState(), instanceOf(ReceivedState.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenDeliveredPackage_whenPrevState_thenStateOrdered() {
|
||||
Package pkg = new Package();
|
||||
pkg.setState(new DeliveredState());
|
||||
pkg.previousState();
|
||||
|
||||
assertThat(pkg.getState(), instanceOf(OrderedState.class));
|
||||
}
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
package com.baeldung.templatemethod.test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.baeldung.templatemethod.model.Computer;
|
||||
import com.baeldung.templatemethod.model.HighEndComputerBuilder;
|
||||
import com.baeldung.templatemethod.model.StandardComputerBuilder;
|
||||
|
||||
public class TemplateMethodPatternIntegrationTest {
|
||||
|
||||
private static StandardComputerBuilder standardComputerBuilder;
|
||||
private static HighEndComputerBuilder highEndComputerBuilder;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpStandardComputerBuilderInstance() {
|
||||
standardComputerBuilder = new StandardComputerBuilder();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpHighEndComputerBuilderInstance() {
|
||||
highEndComputerBuilder = new HighEndComputerBuilder();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenStandardMotherBoard_whenAddingMotherBoard_thenEqualAssertion() {
|
||||
standardComputerBuilder.addMotherboard();
|
||||
assertEquals("Standard Motherboard", standardComputerBuilder.getComputerParts().get("Motherboard"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenStandardMotherboard_whenSetup_thenTwoEqualAssertions() {
|
||||
standardComputerBuilder.setupMotherboard();
|
||||
assertEquals("Screwing the standard motherboard to the case.", standardComputerBuilder.getMotherboardSetupStatus().get(0));
|
||||
assertEquals("Pluging in the power supply connectors.", standardComputerBuilder.getMotherboardSetupStatus().get(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenStandardProcessor_whenAddingProcessor_thenEqualAssertion() {
|
||||
standardComputerBuilder.addProcessor();
|
||||
assertEquals("Standard Processor", standardComputerBuilder.getComputerParts().get("Processor"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenAllStandardParts_whenBuildingComputer_thenTwoParts() {
|
||||
standardComputerBuilder.buildComputer();
|
||||
assertEquals(2, standardComputerBuilder.getComputerParts().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenAllStandardParts_whenComputerisBuilt_thenComputerInstance() {
|
||||
assertThat(standardComputerBuilder.buildComputer(), instanceOf(Computer.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenHighEnddMotherBoard_whenAddingMotherBoard_thenEqualAssertion() {
|
||||
highEndComputerBuilder.addMotherboard();
|
||||
Assert.assertEquals("High-end Motherboard", highEndComputerBuilder.getComputerParts().get("Motherboard"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenHighEnddMotheroboard_whenSetup_thenTwoEqualAssertions() {
|
||||
highEndComputerBuilder.setupMotherboard();
|
||||
assertEquals("Screwing the high-end motherboard to the case.", highEndComputerBuilder.getMotherboardSetupStatus().get(0));
|
||||
assertEquals("Pluging in the power supply connectors.", highEndComputerBuilder.getMotherboardSetupStatus().get(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenHightEndProcessor_whenAddingProcessor_thenEqualAssertion() {
|
||||
highEndComputerBuilder.addProcessor();
|
||||
assertEquals("High-end Processor", highEndComputerBuilder.getComputerParts().get("Processor"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenAllHighEnddParts_whenBuildingComputer_thenTwoParts() {
|
||||
highEndComputerBuilder.buildComputer();
|
||||
assertEquals(2, highEndComputerBuilder.getComputerParts().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenAllHighEndParts_whenComputerisBuilt_thenComputerInstance() {
|
||||
assertThat(standardComputerBuilder.buildComputer(), instanceOf(Computer.class));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user