-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GetAllWorkersInteractor receive Request on execute method
- Loading branch information
Showing
11 changed files
with
139 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...ases/src/main/java/org/reparationservice/usecases/worker/getall/GetAllWorkersRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.reparationservice.usecases.worker.getall; | ||
|
||
import org.reparationservice.entities.worker.WorkerDTO; | ||
import org.reparationservice.requestor.UseCaseRequest; | ||
|
||
import java.util.Collection; | ||
|
||
public class GetAllWorkersRequest extends UseCaseRequest implements GetAllWorkersResponder { | ||
private final GetAllWorkersResponder responder; | ||
|
||
public GetAllWorkersRequest(GetAllWorkersResponder responder) { | ||
this.responder = responder; | ||
} | ||
|
||
@Override public void bindModel(Collection<WorkerDTO> workerList) { | ||
responder.bindModel(workerList); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...c/main/java/org/reparationservice/usecases/worker/getall/GetAllWorkersRequestBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.reparationservice.usecases.worker.getall; | ||
|
||
import org.reparationservice.requestor.UseCaseRequest; | ||
|
||
public interface GetAllWorkersRequestBuilder { | ||
UseCaseRequest buildGetAllWorkersRequest(GetAllWorkersResponder responder); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 39 additions & 24 deletions
63
...c/test/java/org/reparationservice/usecases/worker/getall/GetAllWorkersInteractorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,54 @@ | ||
package org.reparationservice.usecases.worker.getall; | ||
|
||
import static org.junit.Assert.*; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import de.bechte.junit.runners.context.HierarchicalContextRunner; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import org.junit.runner.RunWith; | ||
import org.reparationservice.doubles.GetAllWorkersGatewaySpy; | ||
import org.reparationservice.doubles.GetAllWorkersResponderSpy; | ||
import org.reparationservice.entities.worker.WorkerGateway; | ||
import org.reparationservice.requestor.UseCaseActivator; | ||
import org.reparationservice.requestor.UseCaseRequest; | ||
|
||
@RunWith(HierarchicalContextRunner.class) | ||
public class GetAllWorkersInteractorTest { | ||
@Test(expected = GetAllWorkerInteractor.WorkerGatewayNotNull.class) | ||
|
||
@Test(expected = GetAllWorkerInteractor.WorkerGatewayCannotBeNull.class) | ||
public void throwExceptionWhenNullGatewayPassed() { | ||
new GetAllWorkerInteractor(null, new GetAllWorkersResponderSpy()); | ||
} | ||
|
||
@Test(expected = GetAllWorkerInteractor.PresenterNotNull.class) | ||
public void throwExceptionWhenNullPresenterPassed() { | ||
new GetAllWorkerInteractor(new GetAllWorkersGatewaySpy(), null); | ||
new GetAllWorkerInteractor(null); | ||
} | ||
|
||
@Test | ||
public void returnsAllWorkersWhenExecuteIsCalled() { | ||
GetAllWorkersResponder allWorkersPresenter = new GetAllWorkersResponderSpy(); | ||
WorkerGateway workerGateway = new GetAllWorkersGatewaySpy(); | ||
|
||
UseCaseActivator getAllWorkers = new GetAllWorkerInteractor(workerGateway, allWorkersPresenter); | ||
UseCaseRequest request = null; | ||
getAllWorkers.execute(request); | ||
|
||
GetAllWorkersGatewaySpy workerGatewaySpy = (GetAllWorkersGatewaySpy) workerGateway; | ||
assertTrue(workerGatewaySpy.getAllWorkersWasCalled()); | ||
assertTrue(((GetAllWorkersResponderSpy) allWorkersPresenter).bindModelWasCalled()); | ||
assertEquals(GetAllWorkersGatewaySpy.workerListSize, ((GetAllWorkersResponderSpy) allWorkersPresenter).getWorkerCollection().size()); | ||
|
||
public class InteractorCreated { | ||
private WorkerGateway workerGateway; | ||
private UseCaseActivator getAllWorkers; | ||
|
||
@Before | ||
public void givenInteractor() { | ||
workerGateway = new GetAllWorkersGatewaySpy(); | ||
getAllWorkers = new GetAllWorkerInteractor(workerGateway); | ||
} | ||
|
||
@Test(expected = GetAllWorkerInteractor.GetAllWorkersRequestCannotBeNull.class) | ||
public void throwExceptionWhenNullRequestReceived() { | ||
getAllWorkers.execute(null); | ||
} | ||
|
||
@Test | ||
public void returnsAllWorkersWhenExecuteIsCalled() { | ||
GetAllWorkersResponder responder = new GetAllWorkersResponderSpy(); | ||
GetAllWorkersRequest request = new GetAllWorkersRequest(responder); | ||
|
||
getAllWorkers.execute(request); | ||
|
||
GetAllWorkersGatewaySpy workerGatewaySpy = (GetAllWorkersGatewaySpy) workerGateway; | ||
assertThat(workerGatewaySpy.getAllWorkersWasCalled()).isTrue(); | ||
|
||
GetAllWorkersResponderSpy respSpy = (GetAllWorkersResponderSpy) responder; | ||
assertThat(respSpy.bindModelWasCalled()).isTrue(); | ||
assertThat(GetAllWorkersGatewaySpy.workerListSize) | ||
.isEqualTo(respSpy.getWorkerCollection().size()); | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
.../src/test/java/org/reparationservice/usecases/worker/getall/GetAllWorkersRequestTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.reparationservice.usecases.worker.getall; | ||
|
||
import org.junit.Test; | ||
import org.reparationservice.doubles.GetAllWorkersResponderSpy; | ||
import org.reparationservice.entities.worker.WorkerDTO; | ||
|
||
import java.util.Collection; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class GetAllWorkersRequestTest { | ||
@Test | ||
public void requestIsInstanceOfGetAllWorkersResponder() { | ||
GetAllWorkersResponder responder = new GetAllWorkersResponderSpy(); | ||
GetAllWorkersRequest request = new GetAllWorkersRequest(responder); | ||
|
||
assertThat(request).isInstanceOf(GetAllWorkersResponder.class); | ||
} | ||
|
||
@Test | ||
public void bindModelWasCalled() { | ||
GetAllWorkersResponder responder = new GetAllWorkersResponderSpy(); | ||
GetAllWorkersRequest request = new GetAllWorkersRequest(responder); | ||
|
||
Collection<WorkerDTO> workerList = null; | ||
request.bindModel(workerList); | ||
|
||
GetAllWorkersResponderSpy respSpy = (GetAllWorkersResponderSpy) responder; | ||
assertThat(respSpy.bindModelWasCalled()).isTrue(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters