use of org.opentosca.toscana.core.transformation.properties.OutputProperty in project TOSCAna by StuPro-TOSCAna.
the class TransformationController method getOutputs.
/**
* Returns the outputs of a Transformation.
* <p>
* <table summary="">
* <tr>
* <td>HTTP-Code</td>
* <td>Mime-Type</td>
* <td>Description (Returned if)</td>
* </tr>
* <tr>
* <td>200</td>
* <td>application/hal+json</td>
* <td>Returns a List of the outputs. (Empty if no deployment has been executed)</td>
* </tr>
* <tr>
* <td>400</td>
* <td>application/json</td>
* <td>Returned if the transformation is not in a valid state (has to be in DONE or ERROR) to set inputs</td>
* </tr>
* <tr>
* <td>404</td>
* <td>application/json</td>
* <td>Returns a error message if the csar is not found or if the csar does not have a transformation for the given
* name (see returned error message for details)</td>
* </tr>
* </table>
*/
@ApiOperation(value = "Retrieve the outputs and their values", tags = { "transformations" }, notes = "This operation returns the outputs of a deployment. Retrieval of the outputs is not possible " + "if the transformation (including deployment) is not done yet")
@ApiResponses({ @ApiResponse(code = 200, message = "The operation was executed successfully", response = GetOutputsResponse.class), @ApiResponse(code = 404, message = "There is no CSAR for the given identifier or the CSAR does not have " + "a transformation for the specified platform", response = RestErrorResponse.class), @ApiResponse(code = 400, message = "The state of the transformation is invalid (not ERROR or DONE)", response = RestErrorResponse.class) })
@RequestMapping(path = "/{platform}/outputs", method = { RequestMethod.GET }, produces = "application/hal+json")
public ResponseEntity<GetOutputsResponse> getOutputs(@ApiParam(value = "The unique identifier for the CSAR", required = true, example = "test") @PathVariable(name = "csarId") String csarId, @ApiParam(value = "The identifier for the platform", required = true, example = "kubernetes") @PathVariable(name = "platform") String platformId) {
Csar csar = findByCsarId(csarId);
Transformation transformation = findTransformationByPlatform(csar, platformId);
if (transformation.getState() != TransformationState.DONE && transformation.getState() != TransformationState.ERROR) {
throw new IllegalTransformationStateException("The Transformation has not finished yet!");
}
List<OutputProperty> outputs = transformation.getOutputs();
List<OutputWrap> wrappedOutputs = outputs.stream().map(OutputWrap::new).collect(Collectors.toList());
return ResponseEntity.ok(new GetOutputsResponse(csarId, platformId, wrappedOutputs));
}
use of org.opentosca.toscana.core.transformation.properties.OutputProperty in project TOSCAna by StuPro-TOSCAna.
the class TransformationControllerTest method testGetOutputs.
// </editor-fold>
// <editor-fold desc="Output Tests">
@Test
public void testGetOutputs() throws Exception {
List<Transformation> transformations = preInitNonCreationTests();
Transformation t = transformations.get(0);
when(t.getState()).thenReturn(TransformationState.DONE);
String outputKey = "test_output";
List<OutputProperty> outputs = Lists.newArrayList(new PlatformInput(outputKey, PropertyType.TEXT, "", true, "some value"));
when(t.getOutputs()).thenReturn(outputs);
mvc.perform(get(GET_OUTPUT_URL)).andDo(print()).andExpect(status().is(200)).andExpect(jsonPath("$.outputs").isArray()).andExpect(jsonPath("$.links[0].href").value("http://localhost" + GET_OUTPUT_URL)).andExpect(jsonPath("$.outputs[0].key").value(outputKey)).andReturn();
}
use of org.opentosca.toscana.core.transformation.properties.OutputProperty in project TOSCAna by StuPro-TOSCAna.
the class EffectiveModelTest method outputTest.
@Test
public void outputTest() {
EffectiveModel model = new EffectiveModelFactory().create(TestCsars.Testing.OUTPUTS_TEMPLATE, logMock());
Map<String, OutputProperty> outputs = model.getOutputs();
assertNotNull(outputs);
assertEquals(1, outputs.size());
OutputProperty linkedOutput = outputs.get("test_output_linked");
assertNotNull(linkedOutput);
assertTrue(linkedOutput.getDescription().isPresent());
assertEquals("test-description2", linkedOutput.getDescription().get());
assertTrue(linkedOutput.getValue().isPresent());
assertEquals("8084", linkedOutput.getValue().get());
}
Aggregations