@Test
public void testCreateGetDelete() throws Exception {
assertThatThrownBy(() -> {
- new AuthorativeToscaProvider().getServiceTemplate(null, null, null);
+ new AuthorativeToscaProvider().getServiceTemplateList(null, null, null);
}).hasMessageMatching(DAO_IS_NULL);
ToscaServiceTemplate toscaServiceTemplate = standardCoder.decode(yamlAsJsonString, ToscaServiceTemplate.class);
assertNotNull(toscaServiceTemplate);
ToscaServiceTemplate createdServiceTemplate =
- new AuthorativeToscaProvider().createServiceTemplate(pfDao, toscaServiceTemplate);
+ new AuthorativeToscaProvider().createServiceTemplate(pfDao, toscaServiceTemplate);
PfConceptKey policyTypeKey = new PfConceptKey(POLICY_NO_VERSION_VERSION1);
assertEquals(true, beforePolicyType.getName().equals(createdPolicyType.getName()));
assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), createdPolicyType.getDescription()));
- ToscaServiceTemplate gotServiceTemplate = new AuthorativeToscaProvider().getServiceTemplate(pfDao, null, null);
+ List<ToscaServiceTemplate> gotServiceTemplateList =
+ new AuthorativeToscaProvider().getServiceTemplateList(pfDao, null, null);
- ToscaPolicyType gotPolicyType = gotServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
+ ToscaPolicyType gotPolicyType = gotServiceTemplateList.get(0).getPolicyTypes().get(policyTypeKey.getName());
assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), createdPolicyType.getDescription()));
List<ToscaPolicyType> gotPolicyTypeList =
- new AuthorativeToscaProvider().getPolicyTypeList(pfDao, POLICY_NO_VERSION, VERSION_001);
+ new AuthorativeToscaProvider().getPolicyTypeList(pfDao, POLICY_NO_VERSION, VERSION_001);
assertEquals(2, gotPolicyTypeList.size());
assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
assertEquals(2, gotPolicyTypeList.size());
assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
- assertThatThrownBy(
- () -> new AuthorativeToscaProvider().getPolicyTypeList(new DefaultPfDao(), POLICY_NO_VERSION, VERSION_001))
- .hasMessageContaining("Policy Framework DAO has not been initialized");
+ assertThatThrownBy(() -> new AuthorativeToscaProvider().getPolicyTypeList(new DefaultPfDao(), POLICY_NO_VERSION,
+ VERSION_001)).hasMessageContaining("Policy Framework DAO has not been initialized");
assertTrue(new AuthorativeToscaProvider().getPolicyTypeList(pfDao, "i.dont.Exist", VERSION_001).isEmpty());
ToscaServiceTemplate deletedServiceTemplate =
- new AuthorativeToscaProvider().deleteServiceTemplate(pfDao, "Dummy", "0.0.1");
+ new AuthorativeToscaProvider().deleteServiceTemplate(pfDao, "Dummy", "0.0.1");
assertEquals(2, deletedServiceTemplate.getPolicyTypes().size());
}
@Test
public void testNullParameters() throws Exception {
- assertThatThrownBy(() -> new AuthorativeToscaProvider().getServiceTemplate(null, null, null))
- .hasMessageMatching("^dao is marked .*on.*ull but is null$");
+ assertThatThrownBy(() -> new AuthorativeToscaProvider().getServiceTemplateList(null, null, null))
+ .hasMessageMatching("^dao is marked .*on.*ull but is null$");
assertThatThrownBy(() -> new AuthorativeToscaProvider().createServiceTemplate(null, null))
- .hasMessageMatching("^dao is marked .*on.*ull but is null$");
+ .hasMessageMatching("^dao is marked .*on.*ull but is null$");
assertThatThrownBy(() -> new AuthorativeToscaProvider().createServiceTemplate(pfDao, null))
- .hasMessageMatching("^serviceTemplate is marked .*on.*ull but is null$");
+ .hasMessageMatching("^serviceTemplate is marked .*on.*ull but is null$");
assertThatThrownBy(() -> new AuthorativeToscaProvider().createServiceTemplate(null, new ToscaServiceTemplate()))
- .hasMessageMatching("^dao is marked .*on.*ull but is null$");
+ .hasMessageMatching("^dao is marked .*on.*ull but is null$");
assertThatThrownBy(() -> new AuthorativeToscaProvider().deleteServiceTemplate(null, null, null))
- .hasMessageMatching("^dao is marked .*on.*ull but is null$");
+ .hasMessageMatching("^dao is marked .*on.*ull but is null$");
assertThatThrownBy(() -> new AuthorativeToscaProvider().deleteServiceTemplate(null, null, "0.0.1"))
- .hasMessageMatching("^dao is marked .*on.*ull but is null$");
+ .hasMessageMatching("^dao is marked .*on.*ull but is null$");
assertThatThrownBy(() -> new AuthorativeToscaProvider().deleteServiceTemplate(null, "Dummy", null))
- .hasMessageMatching("^dao is marked .*on.*ull but is null$");
+ .hasMessageMatching("^dao is marked .*on.*ull but is null$");
assertThatThrownBy(() -> new AuthorativeToscaProvider().deleteServiceTemplate(null, "Dummy", "0.0.1"))
- .hasMessageMatching("^dao is marked .*on.*ull but is null$");
+ .hasMessageMatching("^dao is marked .*on.*ull but is null$");
assertThatThrownBy(() -> new AuthorativeToscaProvider().deleteServiceTemplate(pfDao, null, null))
- .hasMessageMatching("^name is marked .*on.*ull but is null$");
+ .hasMessageMatching("^name is marked .*on.*ull but is null$");
assertThatThrownBy(() -> new AuthorativeToscaProvider().deleteServiceTemplate(pfDao, null, "0.0.1"))
- .hasMessageMatching("^name is marked .*on.*ull but is null$");
+ .hasMessageMatching("^name is marked .*on.*ull but is null$");
assertThatThrownBy(() -> new AuthorativeToscaProvider().deleteServiceTemplate(pfDao, "Dummy", null))
- .hasMessageMatching("^version is marked .*on.*ull but is null$");
+ .hasMessageMatching("^version is marked .*on.*ull but is null$");
}
}