diff --git a/api-lib-core/src/test/java/de/ozgcloud/apilib/common/command/grpc/GrpcExistsPendingCommandsResponseTestFactory.java b/api-lib-core/src/test/java/de/ozgcloud/apilib/common/command/grpc/GrpcExistsPendingCommandsResponseTestFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..4a78217021a4f3848d7a2fc0075abc1bca4d77da --- /dev/null +++ b/api-lib-core/src/test/java/de/ozgcloud/apilib/common/command/grpc/GrpcExistsPendingCommandsResponseTestFactory.java @@ -0,0 +1,17 @@ +package de.ozgcloud.apilib.common.command.grpc; + +import de.ozgcloud.vorgang.grpc.command.GrpcExistsPendingCommandsResponse; +import de.ozgcloud.vorgang.grpc.command.GrpcExistsPendingCommandsResponse.Builder; + +public class GrpcExistsPendingCommandsResponseTestFactory { + + public static final boolean EXISTS_PENDING_COMMAND = true; + + public static GrpcExistsPendingCommandsResponse create() { + return createBuilder().build(); + } + + public static Builder createBuilder() { + return GrpcExistsPendingCommandsResponse.newBuilder().setExistsPendingCommands(EXISTS_PENDING_COMMAND); + } +} diff --git a/api-lib-core/src/test/java/de/ozgcloud/apilib/common/command/grpc/GrpcGetPendingCommandsResponseTestFactory.java b/api-lib-core/src/test/java/de/ozgcloud/apilib/common/command/grpc/GrpcGetPendingCommandsResponseTestFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..ac9726ecb62105e061e73e948428a84cac7ab9cd --- /dev/null +++ b/api-lib-core/src/test/java/de/ozgcloud/apilib/common/command/grpc/GrpcGetPendingCommandsResponseTestFactory.java @@ -0,0 +1,18 @@ +package de.ozgcloud.apilib.common.command.grpc; + +import de.ozgcloud.vorgang.grpc.command.GrpcCommand; +import de.ozgcloud.vorgang.grpc.command.GrpcGetPendingCommandsResponse; +import de.ozgcloud.vorgang.grpc.command.GrpcGetPendingCommandsResponse.Builder; + +public class GrpcGetPendingCommandsResponseTestFactory { + + public static final GrpcCommand GRPC_COMMAND = GrpcCommandTestFactory.create(); + + public static GrpcGetPendingCommandsResponse create() { + return createBuilder().build(); + } + + public static Builder createBuilder() { + return GrpcGetPendingCommandsResponse.newBuilder().addCommand(GRPC_COMMAND); + } +} diff --git a/api-lib-core/src/test/java/de/ozgcloud/apilib/common/command/grpc/GrpcOzgCloudCommandServiceTest.java b/api-lib-core/src/test/java/de/ozgcloud/apilib/common/command/grpc/GrpcOzgCloudCommandServiceTest.java index fa44afb6f51a9495dd48517d1578c8b46d0926ad..3d8eebcdc4fd51502389d94402bbed8e4fb00062 100644 --- a/api-lib-core/src/test/java/de/ozgcloud/apilib/common/command/grpc/GrpcOzgCloudCommandServiceTest.java +++ b/api-lib-core/src/test/java/de/ozgcloud/apilib/common/command/grpc/GrpcOzgCloudCommandServiceTest.java @@ -28,7 +28,6 @@ import de.ozgcloud.vorgang.grpc.command.GrpcCommandsResponse; import de.ozgcloud.vorgang.grpc.command.GrpcExistsPendingCommandsRequest; import de.ozgcloud.vorgang.grpc.command.GrpcExistsPendingCommandsResponse; import de.ozgcloud.vorgang.grpc.command.GrpcGetPendingCommandsRequest; -import de.ozgcloud.vorgang.grpc.command.GrpcGetPendingCommandsResponse; class GrpcOzgCloudCommandServiceTest { @@ -220,7 +219,7 @@ class GrpcOzgCloudCommandServiceTest { void mock() { doReturn(serviceStubWithInterceptor).when(service).getCommandServiceStub(); doReturn(request).when(service).buildExistsPendingCommandRequest(OzgCloudVorgangTestFactory.ID); - var response = GrpcExistsPendingCommandsResponse.newBuilder().setExistsPendingCommands(true).build(); + var response = GrpcExistsPendingCommandsResponseTestFactory.create(); when(serviceStubWithInterceptor.existsPendingCommands(any())).thenReturn(response); } @@ -280,14 +279,13 @@ class GrpcOzgCloudCommandServiceTest { @Mock private CommandServiceBlockingStub serviceStubWithInterceptor; - private final GrpcCommand grpcCommand = GrpcCommandTestFactory.create(); private final OzgCloudCommand command = OzgCloudCommandTestFactory.create(); @BeforeEach void mock() { doReturn(serviceStubWithInterceptor).when(service).getCommandServiceStub(); doReturn(request).when(service).buildGetPendingCommandRequest(any()); - var response = GrpcGetPendingCommandsResponse.newBuilder().addCommand(grpcCommand).build(); + var response = GrpcGetPendingCommandsResponseTestFactory.create(); when(serviceStubWithInterceptor.getPendingCommands(any())).thenReturn(response); } @@ -316,12 +314,12 @@ class GrpcOzgCloudCommandServiceTest { void shouldCallMapper() { getPendingCommands(); - verify(mapper).fromGrpc(grpcCommand); + verify(mapper).fromGrpc(GrpcGetPendingCommandsResponseTestFactory.GRPC_COMMAND); } @Test void shouldReturnPendingCommands() { - when(mapper.fromGrpc(grpcCommand)).thenReturn(command); + when(mapper.fromGrpc(GrpcGetPendingCommandsResponseTestFactory.GRPC_COMMAND)).thenReturn(command); var result = getPendingCommands();