@Test public void shouldPreserveShapesForUnsupportedShapeKind() { DataShape xmlSchape = new DataShape.Builder() .kind(DataShapeKinds.XML_SCHEMA_INSPECTED) .specification("</>") .putMetadata("something", "else") .build(); final DynamicActionMetadata givenMetadata = new DynamicActionMetadata.Builder() .inputShape(xmlSchape) .outputShape(xmlSchape) .build(); final Response response = handler.enrichStepMetadata(StepKind.split.name(), givenMetadata); @SuppressWarnings("unchecked") final Meta<StepDescriptor> meta = (Meta<StepDescriptor>) response.getEntity(); final StepDescriptor descriptor = meta.getValue(); assertThat(descriptor.getInputDataShape()).contains(xmlSchape); assertThat(descriptor.getOutputDataShape()).contains(xmlSchape); }
@POST @Path("/descriptor") @Produces(MediaType.APPLICATION_JSON) @Operation(description = "Retrieves enriched step definitions, that is a list of steps where each step has adapted input/output data shapes " + "defined with respect to the given shape variants") @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Step.class))), description = "List of enriched steps") public Response enrichStepMetadata(List<Step> steps) { List<Step> enriched = new ArrayList<>(steps.size()); for (int i = 0; i < steps.size(); i++) { Step step = steps.get(i); final Optional<StepMetadataHandler> metadataHandler = findStepMetadataHandler(step.getStepKind()); if (metadataHandler.isPresent()) { StepMetadataHandler handler = metadataHandler.get(); List<Step> previousSteps; if (i == 0) { previousSteps = Collections.singletonList(step); } else { previousSteps = enriched.subList(0, i); } final DynamicActionMetadata metadata = handler.createMetadata(step, previousSteps, steps.subList(i + 1, steps.size())); final DynamicActionMetadata enrichedMetadata = handler.handle(metadata); if (enrichedMetadata.equals(DynamicActionMetadata.NOTHING)) { enriched.add(step); } else { enriched.add(applyMetadata(step, enrichedMetadata)); } } else { enriched.add(step); } } return Response.status(Status.OK).entity(enriched).build(); }
StepActionHandler extends BaseHandler { @POST @Path("/descriptor") @Produces(MediaType.APPLICATION_JSON) @Operation(description = "Retrieves enriched step definitions, that is a list of steps where each step has adapted input/output data shapes " + "defined with respect to the given shape variants") @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Step.class))), description = "List of enriched steps") public Response enrichStepMetadata(List<Step> steps) { List<Step> enriched = new ArrayList<>(steps.size()); for (int i = 0; i < steps.size(); i++) { Step step = steps.get(i); final Optional<StepMetadataHandler> metadataHandler = findStepMetadataHandler(step.getStepKind()); if (metadataHandler.isPresent()) { StepMetadataHandler handler = metadataHandler.get(); List<Step> previousSteps; if (i == 0) { previousSteps = Collections.singletonList(step); } else { previousSteps = enriched.subList(0, i); } final DynamicActionMetadata metadata = handler.createMetadata(step, previousSteps, steps.subList(i + 1, steps.size())); final DynamicActionMetadata enrichedMetadata = handler.handle(metadata); if (enrichedMetadata.equals(DynamicActionMetadata.NOTHING)) { enriched.add(step); } else { enriched.add(applyMetadata(step, enrichedMetadata)); } } else { enriched.add(step); } } return Response.status(Status.OK).entity(enriched).build(); } }
StepActionHandler extends BaseHandler { @POST @Path("/descriptor") @Produces(MediaType.APPLICATION_JSON) @Operation(description = "Retrieves enriched step definitions, that is a list of steps where each step has adapted input/output data shapes " + "defined with respect to the given shape variants") @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Step.class))), description = "List of enriched steps") public Response enrichStepMetadata(List<Step> steps) { List<Step> enriched = new ArrayList<>(steps.size()); for (int i = 0; i < steps.size(); i++) { Step step = steps.get(i); final Optional<StepMetadataHandler> metadataHandler = findStepMetadataHandler(step.getStepKind()); if (metadataHandler.isPresent()) { StepMetadataHandler handler = metadataHandler.get(); List<Step> previousSteps; if (i == 0) { previousSteps = Collections.singletonList(step); } else { previousSteps = enriched.subList(0, i); } final DynamicActionMetadata metadata = handler.createMetadata(step, previousSteps, steps.subList(i + 1, steps.size())); final DynamicActionMetadata enrichedMetadata = handler.handle(metadata); if (enrichedMetadata.equals(DynamicActionMetadata.NOTHING)) { enriched.add(step); } else { enriched.add(applyMetadata(step, enrichedMetadata)); } } else { enriched.add(step); } } return Response.status(Status.OK).entity(enriched).build(); } StepActionHandler(final DataManager dataMgr); }
StepActionHandler extends BaseHandler { @POST @Path("/descriptor") @Produces(MediaType.APPLICATION_JSON) @Operation(description = "Retrieves enriched step definitions, that is a list of steps where each step has adapted input/output data shapes " + "defined with respect to the given shape variants") @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Step.class))), description = "List of enriched steps") public Response enrichStepMetadata(List<Step> steps) { List<Step> enriched = new ArrayList<>(steps.size()); for (int i = 0; i < steps.size(); i++) { Step step = steps.get(i); final Optional<StepMetadataHandler> metadataHandler = findStepMetadataHandler(step.getStepKind()); if (metadataHandler.isPresent()) { StepMetadataHandler handler = metadataHandler.get(); List<Step> previousSteps; if (i == 0) { previousSteps = Collections.singletonList(step); } else { previousSteps = enriched.subList(0, i); } final DynamicActionMetadata metadata = handler.createMetadata(step, previousSteps, steps.subList(i + 1, steps.size())); final DynamicActionMetadata enrichedMetadata = handler.handle(metadata); if (enrichedMetadata.equals(DynamicActionMetadata.NOTHING)) { enriched.add(step); } else { enriched.add(applyMetadata(step, enrichedMetadata)); } } else { enriched.add(step); } } return Response.status(Status.OK).entity(enriched).build(); } StepActionHandler(final DataManager dataMgr); @POST @Path("/descriptor") @Produces(MediaType.APPLICATION_JSON) @Operation(description = "Retrieves enriched step definitions, that is a list of steps where each step has adapted input/output data shapes " + "defined with respect to the given shape variants") @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Step.class))), description = "List of enriched steps") Response enrichStepMetadata(List<Step> steps); @POST @Path("/{kind}/descriptor") @Produces(MediaType.APPLICATION_JSON) @Operation(description = "Retrieves enriched step definition, that is an step descriptor that has input/output data shapes " + "defined with respect to the given shape variants") @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = StepDescriptor.class)), description = "Enriched step descriptor") Response enrichStepMetadata(
        @PathParam("kind") @Parameter(required = true) final String kind,
        DynamicActionMetadata metadata); }
StepActionHandler extends BaseHandler { @POST @Path("/descriptor") @Produces(MediaType.APPLICATION_JSON) @Operation(description = "Retrieves enriched step definitions, that is a list of steps where each step has adapted input/output data shapes " + "defined with respect to the given shape variants") @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Step.class))), description = "List of enriched steps") public Response enrichStepMetadata(List<Step> steps) { List<Step> enriched = new ArrayList<>(steps.size()); for (int i = 0; i < steps.size(); i++) { Step step = steps.get(i); final Optional<StepMetadataHandler> metadataHandler = findStepMetadataHandler(step.getStepKind()); if (metadataHandler.isPresent()) { StepMetadataHandler handler = metadataHandler.get(); List<Step> previousSteps; if (i == 0) { previousSteps = Collections.singletonList(step); } else { previousSteps = enriched.subList(0, i); } final DynamicActionMetadata metadata = handler.createMetadata(step, previousSteps, steps.subList(i + 1, steps.size())); final DynamicActionMetadata enrichedMetadata = handler.handle(metadata); if (enrichedMetadata.equals(DynamicActionMetadata.NOTHING)) { enriched.add(step); } else { enriched.add(applyMetadata(step, enrichedMetadata)); } } else { enriched.add(step); } } return Response.status(Status.OK).entity(enriched).build(); } StepActionHandler(final DataManager dataMgr); @POST @Path("/descriptor") @Produces(MediaType.APPLICATION_JSON) @Operation(description = "Retrieves enriched step definitions, that is a list of steps where each step has adapted input/output data shapes " + "defined with respect to the given shape variants") @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Step.class))), description = "List of enriched steps") Response enrichStepMetadata(List<Step> steps); @POST @Path("/{kind}/descriptor") @Produces(MediaType.APPLICATION_JSON) @Operation(description = "Retrieves enriched step definition, that is an step descriptor that has input/output data shapes " + "defined with respect to the given shape variants") @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = StepDescriptor.class)), description = "Enriched step descriptor") Response enrichStepMetadata(
        @PathParam("kind") @Parameter(required = true) final String kind,
        DynamicActionMetadata metadata);  }