use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.DeployResourceRequest in project zeebe-process-test by camunda-cloud.
the class GrpcToLogStreamGateway method deployResource.
@Override
public void deployResource(final DeployResourceRequest request, final StreamObserver<DeployResourceResponse> responseObserver) {
final Long requestId = gatewayRequestStore.registerNewRequest(request.getClass(), responseObserver);
final RecordMetadata recordMetadata = prepareRecordMetadata().requestId(requestId).valueType(ValueType.DEPLOYMENT).intent(DeploymentIntent.CREATE);
final DeploymentRecord deploymentRecord = new DeploymentRecord();
final ValueArray<DeploymentResource> resources = deploymentRecord.resources();
request.getResourcesList().forEach((resource -> resources.add().setResourceName(resource.getName()).setResource(resource.getContent().toByteArray())));
writer.writeCommandWithoutKey(deploymentRecord, recordMetadata);
}
use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.DeployResourceRequest in project zeebe by zeebe-io.
the class TestInterceptor method interceptCall.
@Override
public <ReqT, RespT> Listener<ReqT> interceptCall(final ServerCall<ReqT, RespT> call, final Metadata headers, final ServerCallHandler<ReqT, RespT> next) {
final var listener = next.startCall(call, headers);
return new CloseAwareListener<>(listener) {
@Override
public void onMessage(final ReqT message) {
if (message instanceof DeployResourceRequest) {
call.close(Status.PERMISSION_DENIED.augmentDescription(ERROR_MESSAGE), new Metadata());
isClosed = true;
return;
}
super.onMessage(message);
}
};
}
use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.DeployResourceRequest in project zeebe by zeebe-io.
the class DeployResourceTest method shouldDeployResourceFromFile.
@Test
public void shouldDeployResourceFromFile() {
// given
final String path = DeployResourceTest.class.getResource(BPMN_1_FILENAME).getPath();
// when
client.newDeployResourceCommand().addResourceFile(path).send().join();
// then
final DeployResourceRequest request = gatewayService.getLastRequest();
final Resource resource = request.getResources(0);
assertThat(resource.getName()).isEqualTo(path);
assertThat(resource.getContent().toByteArray()).isEqualTo(getBytes(BPMN_1_FILENAME));
}
use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.DeployResourceRequest in project zeebe by zeebe-io.
the class DeployResourceTest method shouldDeployMultipleResources.
@Test
public void shouldDeployMultipleResources() {
// given
final long key = 345L;
final String filename1 = BPMN_1_FILENAME.substring(1);
final String filename2 = BPMN_2_FILENAME.substring(1);
gatewayService.onDeployResourceRequest(key, deployment(deployedProcess(BPMN_1_PROCESS_ID, 1, 1, filename1)), deployment(deployedProcess(BPMN_2_PROCESS_ID, 1, 2, filename2)));
// when
client.newDeployResourceCommand().addResourceFromClasspath(filename1).addResourceFromClasspath(filename2).send().join();
// then
final DeployResourceRequest request = gatewayService.getLastRequest();
assertThat(request.getResourcesList()).hasSize(2);
final Resource resource1 = request.getResources(0);
assertThat(resource1.getName()).isEqualTo(filename1);
assertThat(resource1.getContent().toByteArray()).isEqualTo(getBytes(BPMN_1_FILENAME));
final Resource resource2 = request.getResources(1);
assertThat(resource2.getName()).isEqualTo(filename2);
assertThat(resource2.getContent().toByteArray()).isEqualTo(getBytes(BPMN_2_FILENAME));
}
use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.DeployResourceRequest in project zeebe by zeebe-io.
the class DeployResourceTest method shouldDeployResourceFromInputStream.
@Test
public void shouldDeployResourceFromInputStream() {
// given
final String filename = BPMN_1_FILENAME;
final InputStream resourceAsStream = DeployResourceTest.class.getResourceAsStream(filename);
// when
client.newDeployResourceCommand().addResourceStream(resourceAsStream, filename).send().join();
// then
final DeployResourceRequest request = gatewayService.getLastRequest();
final Resource resource = request.getResources(0);
assertThat(resource.getName()).isEqualTo(filename);
assertThat(resource.getContent().toByteArray()).isEqualTo(getBytes(BPMN_1_FILENAME));
}
Aggregations