aboutsummaryrefslogtreecommitdiffstats
path: root/runtime-acm/src/test
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2023-11-20 10:07:44 +0000
committerFrancescoFioraEst <francesco.fiora@est.tech>2023-11-20 15:15:18 +0000
commit61571e7b5119793bbbfb8942db5765d16fbd4fdf (patch)
tree2a84ca788caec28dd4435b18f264306ad5a4babc /runtime-acm/src/test
parent3276371eda89578e4fe3ad2ce348d1da6e22ff3f (diff)
Fix missing error message in ACM
Issue-ID: POLICY-4872 Change-Id: I2f7769a3bb1f6aa168f8d59ff99cb0774aee5ed7 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'runtime-acm/src/test')
-rwxr-xr-xruntime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java25
1 files changed, 24 insertions, 1 deletions
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java
index b2e151126..6c5417286 100755
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java
@@ -47,6 +47,7 @@ import org.onap.policy.clamp.models.acm.messages.rest.commissioning.PrimeOrder;
import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider;
import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider;
import org.onap.policy.models.tosca.authorative.concepts.ToscaDataType;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.springframework.beans.factory.annotation.Autowired;
@@ -112,7 +113,29 @@ class CommissioningControllerTest extends CommonRestController {
assertThat(Response.Status.BAD_REQUEST.getStatusCode()).isEqualTo(resp.getStatus());
var commissioningResponse = resp.readEntity(CommissioningResponse.class);
- assertThat(commissioningResponse.getErrorDetails()).isNotNull();
+ assertThat(commissioningResponse.getErrorDetails())
+ .isEqualTo("org.springframework.http.converter.HttpMessageNotReadableException "
+ + "Bad Request Could not read JSON: java.lang.IllegalStateException: "
+ + "Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $");
+ assertThat(commissioningResponse.getAffectedAutomationCompositionDefinitions()).isNull();
+ }
+
+ @Test
+ void testCreateBadVersion() {
+ var serviceTemplateCreate = new ToscaServiceTemplate(serviceTemplate);
+ var x = new ToscaNodeTemplate(serviceTemplateCreate
+ .getToscaTopologyTemplate().getNodeTemplates().values().iterator().next());
+ x.setVersion("1.0.wrong");
+ serviceTemplateCreate.getToscaTopologyTemplate().getNodeTemplates().put(x.getName(), x);
+
+ var invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT);
+ var resp = invocationBuilder.post(Entity.json(serviceTemplateCreate));
+
+ assertThat(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).isEqualTo(resp.getStatus());
+ var commissioningResponse = resp.readEntity(CommissioningResponse.class);
+ assertThat(commissioningResponse.getErrorDetails())
+ .isEqualTo("java.lang.IllegalArgumentException Internal Server Error parameter "
+ + "\"version\": value \"1.0.wrong\", does not match regular expression \"^(\\d+.){2}\\d+$\"");
assertThat(commissioningResponse.getAffectedAutomationCompositionDefinitions()).isNull();
}