<setHeader name="Content-Type">
<constant>application/json</constant>
</setHeader>
- <setProperty name="name">
- <simple>${header.name}</simple>
- </setProperty>
- <setProperty name="version">
- <simple>${header.version}</simple>
- </setProperty>
<log loggingLevel="INFO"
message="Endpoint to get Tosca Instantiation: {{clamp.config.controlloop.runtime.url}}/onap/controlloop/v2/instantiation"></log>
<toD
- uri="{{clamp.config.controlloop.runtime.url}}/onap/controlloop/v2/instantiation?name=${exchangeProperty[name]}&version=${exchangeProperty[version]}&bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.controlloop.runtime.userName}}&authPassword={{clamp.config.controlloop.runtime.password}}&authenticationPreemptive=true&connectionClose=true"/>
+ uri="{{clamp.config.controlloop.runtime.url}}/onap/controlloop/v2/instantiation?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.controlloop.runtime.userName}}&authPassword={{clamp.config.controlloop.runtime.password}}&authenticationPreemptive=true&connectionClose=true"/>
<convertBodyTo type="java.lang.String"/>
<doFinally>
<to uri="direct:reset-raise-http-exception-flag"/>
<log loggingLevel="INFO"
message="Endpoint to send Tosca Instance Properties: {{clamp.config.controlloop.runtime.url}}/onap/controlloop/v2/instanceProperties"></log>
<toD
- uri="{{clamp.config.controlloop.runtime.url}}/onap/controlloop/v2/instanceProperties? bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.controlloop.runtime.userName}}&authPassword={{clamp.config.controlloop.runtime.password}}&authenticationPreemptive=true&connectionClose=true"/>
+ uri="{{clamp.config.controlloop.runtime.url}}/onap/controlloop/v2/instanceProperties?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.controlloop.runtime.userName}}&authPassword={{clamp.config.controlloop.runtime.password}}&authenticationPreemptive=true&connectionClose=true"/>
<convertBodyTo type="java.lang.String"/>
<doFinally>
<to uri="direct:reset-raise-http-exception-flag"/>
private static final String DIRECT_GET_TOSCA_INSTANTIATION = "direct:get-tosca-instantiation";
- private static final String DIRECT_POST_TOSCA_INSTANTANCE_PROPERTIES = "direct:post-tosca-instance-properties";
+ private static final String DIRECT_POST_TOSCA_INSTANCE_PROPERTIES = "direct:post-tosca-instance-properties";
+
+ private static final String DIRECT_DELETE_TOSCA_INSTANCE_PROPERTIES = "direct:delete-tosca-instance-properties";
+
+ private static final String DIRECT_PUT_TOSCA_INSTANCE_PROPERTIES = "direct:put-tosca-instantiation";
private static final String SERVICE_TEMPLATE_NAME = "name";
+ " \"topology_template\": {},"
+ " \"name\": \"ToscaServiceTemplateSimple\", \"version\": \"1.0.0\", \"metadata\": {}}";
+ private static final String SAMPLE_TOSCA_CHANGE_ORDER_STATE = "{\"orderedState\":\"PASSIVE\","
+ + "\"controlLoopIdentifierList\":[{\"name\":\"PMSH_Instance1\",\"version\":\"2.3.1\"}]}";
+
@Test
public void testToscaServiceTemplateStatus() {
ProducerTemplate prodTemplate = camelContext.createProducerTemplate();
}
@Test
- public void testCommissioningOfToscaServiceTemplateStatus() {
+ public void testCreateToscaInstancePropertiesStatus() {
ProducerTemplate prodTemplate = camelContext.createProducerTemplate();
Exchange exchangeResponse =
- prodTemplate.send(DIRECT_POST_TOSCA_INSTANTANCE_PROPERTIES, ExchangeBuilder.anExchange(camelContext)
+ prodTemplate.send(DIRECT_POST_TOSCA_INSTANCE_PROPERTIES, ExchangeBuilder.anExchange(camelContext)
.withBody(SAMPLE_TOSCA_TEMPLATE)
.withProperty("raiseHttpExceptionFlag", "true")
.build());
assertThat(HttpStatus.valueOf((Integer) exchangeResponse.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE))
.is2xxSuccessful()).isTrue();
}
+
+ @Test
+ public void testDeleteToscaInstancePropertiesStatus() {
+ ProducerTemplate prodTemplate = camelContext.createProducerTemplate();
+
+ Exchange exchangeResponse =
+ prodTemplate.send(DIRECT_DELETE_TOSCA_INSTANCE_PROPERTIES, ExchangeBuilder.anExchange(camelContext)
+ .withProperty("name", "PMSH_Instance1")
+ .withProperty("version", "2.3.1")
+ .withProperty("raiseHttpExceptionFlag", "true")
+ .build());
+
+ assertThat(HttpStatus.valueOf((Integer) exchangeResponse.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE))
+ .is2xxSuccessful()).isTrue();
+ }
+
+ @Test
+ public void testChangeOrderStateStatus() {
+ ProducerTemplate prodTemplate = camelContext.createProducerTemplate();
+
+ Exchange exchangeResponse =
+ prodTemplate.send(DIRECT_PUT_TOSCA_INSTANCE_PROPERTIES, ExchangeBuilder.anExchange(camelContext)
+ .withBody(SAMPLE_TOSCA_CHANGE_ORDER_STATE)
+ .withProperty("raiseHttpExceptionFlag", "true")
+ .build());
+
+ assertThat(HttpStatus.valueOf((Integer) exchangeResponse.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE))
+ .is2xxSuccessful()).isTrue();
+ }
}
with open(cached_file_content, 'w+') as f:
f.write(self.data_string)
return True
+ elif (self.path.startswith("/onap/controlloop/v2/instanceProperties")) and http_type == "DELETE":
+ print("self.path start with /instanceProperties Deleting instance properties, generating response json...")
+ jsonGenerated = "{\"errorDetails\": null,\"affectedControlLoopDefinitions\": [{ \"name\": \"PMSH_Instance1\", \"version\": \"2.3.1\" }]}"
+ self._create_cache(jsonGenerated, cached_file_folder, cached_file_header, cached_file_content)
+ return True
+ elif (self.path.startswith("/onap/controlloop/v2/instantiation/command")) and http_type == "PUT":
+ print("self.path start with /instantiation/command Changing order state, generating response json...")
+ jsonGenerated = "{\"orderedState\":\"PASSIVE\",\"controlLoopIdentifierList\":[{\"name\":\"PMSH_Instance1\",\"version\":\"2.3.1\"}]}"
+ self._create_cache(jsonGenerated, cached_file_folder, cached_file_header, cached_file_content)
+ return True
else:
return False