aboutsummaryrefslogtreecommitdiffstats
path: root/models/src/test/java/org
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2022-11-14 10:49:34 +0000
committerFrancesco Fiora <francesco.fiora@est.tech>2022-11-14 14:45:18 +0000
commitc32d7926409b4c164e2a5097e7ba1bc4d766bd5b (patch)
treec0beffd2b72a7eb06db7eb0f9e3c687c24d1ded7 /models/src/test/java/org
parentcfa51e6177b801fcf456390cdaea520b6378de39 (diff)
Remove redundant endpoints in ACM
Remove redundant endpoints in ACM not present in the new generated Api code. Issue-ID: POLICY-4453 Change-Id: I4b843c2637e934f8a29f71d8031bdfe903ff20dc Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'models/src/test/java/org')
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java66
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ServiceTemplateProviderTest.java15
2 files changed, 5 insertions, 76 deletions
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java
index 3228347e9..e381693ee 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java
@@ -27,7 +27,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.List;
@@ -40,15 +39,12 @@ import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions;
import org.onap.policy.clamp.models.acm.persistence.concepts.JpaAutomationComposition;
import org.onap.policy.clamp.models.acm.persistence.repository.AutomationCompositionRepository;
import org.onap.policy.clamp.models.acm.persistence.repository.ToscaNodeTemplateRepository;
-import org.onap.policy.clamp.models.acm.persistence.repository.ToscaNodeTemplatesRepository;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.StandardCoder;
-import org.onap.policy.common.utils.coder.YamlJsonTranslator;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate;
@@ -65,9 +61,6 @@ class AutomationCompositionProviderTest {
private static final Coder CODER = new StandardCoder();
private static final String AUTOMATION_COMPOSITION_JSON =
"src/test/resources/providers/TestAutomationCompositions.json";
- private static final String TOSCA_TEMPLATE_YAML = "examples/acm/test-pm-subscription-handling.yaml";
-
- private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator();
private AutomationCompositions inputAutomationCompositions;
private List<JpaAutomationComposition> inputAutomationCompositionsJpa;
@@ -85,7 +78,7 @@ class AutomationCompositionProviderTest {
void testAutomationCompositionsSave() throws Exception {
var automationCompositionRepository = mock(AutomationCompositionRepository.class);
var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository,
- mock(ToscaNodeTemplateRepository.class), mock(ToscaNodeTemplatesRepository.class));
+ mock(ToscaNodeTemplateRepository.class));
assertThatThrownBy(() -> automationCompositionProvider.saveAutomationCompositions(null))
.hasMessageMatching(LIST_IS_NULL);
@@ -110,7 +103,7 @@ class AutomationCompositionProviderTest {
void testAutomationCompositionSave() throws Exception {
var automationCompositionRepository = mock(AutomationCompositionRepository.class);
var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository,
- mock(ToscaNodeTemplateRepository.class), mock(ToscaNodeTemplatesRepository.class));
+ mock(ToscaNodeTemplateRepository.class));
assertThatThrownBy(() -> automationCompositionProvider.saveAutomationComposition(null))
.hasMessageMatching(OBJECT_IS_NULL);
@@ -134,7 +127,7 @@ class AutomationCompositionProviderTest {
void testGetAutomationCompositions() throws Exception {
var automationCompositionRepository = mock(AutomationCompositionRepository.class);
var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository,
- mock(ToscaNodeTemplateRepository.class), mock(ToscaNodeTemplatesRepository.class));
+ mock(ToscaNodeTemplateRepository.class));
// Return empty list when no data present in db
List<AutomationComposition> getResponse = automationCompositionProvider.getAutomationCompositions();
@@ -193,7 +186,7 @@ class AutomationCompositionProviderTest {
void testDeleteAutomationComposition() throws Exception {
var automationCompositionRepository = mock(AutomationCompositionRepository.class);
var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository,
- mock(ToscaNodeTemplateRepository.class), mock(ToscaNodeTemplatesRepository.class));
+ mock(ToscaNodeTemplateRepository.class));
assertThatThrownBy(() -> automationCompositionProvider
.deleteAutomationComposition(ID_NAME_NOT_EXTST, ID_VERSION))
@@ -211,49 +204,10 @@ class AutomationCompositionProviderTest {
}
@Test
- void testDeleteAllInstanceProperties() throws Exception {
- var automationCompositionProvider =
- new AutomationCompositionProvider(mock(AutomationCompositionRepository.class),
- mock(ToscaNodeTemplateRepository.class), mock(ToscaNodeTemplatesRepository.class));
- var toscaServiceTemplate = testAutomationCompositionRead();
- automationCompositionProvider.deleteInstanceProperties(
- automationCompositionProvider.saveInstanceProperties(toscaServiceTemplate),
- automationCompositionProvider.getAllNodeTemplates());
- assertThat(automationCompositionProvider.getAutomationCompositions()).isEmpty();
- }
-
- @Test
- void testSaveAndDeleteInstanceProperties() {
- var toscaNodeTemplatesRepository = mock(ToscaNodeTemplatesRepository.class);
- var toscaNodeTemplateRepository = mock(ToscaNodeTemplateRepository.class);
- var automationCompositionProvider = new AutomationCompositionProvider(
- mock(AutomationCompositionRepository.class), toscaNodeTemplateRepository, toscaNodeTemplatesRepository);
- var toscaServiceTest = testAutomationCompositionRead();
-
- automationCompositionProvider.saveInstanceProperties(toscaServiceTest);
- verify(toscaNodeTemplatesRepository).save(any());
-
- var name = "org.onap.policy.acm.PolicyAutomationCompositionParticipant";
- var version = "2.3.1";
- var elem = toscaServiceTest.getToscaTopologyTemplate().getNodeTemplates().get(name);
- when(toscaNodeTemplateRepository.getFiltered(JpaToscaNodeTemplate.class, name, version))
- .thenReturn(List.of(new JpaToscaNodeTemplate(elem)));
-
- var filtered = automationCompositionProvider.getNodeTemplates(name, version);
- verify(toscaNodeTemplateRepository).getFiltered(JpaToscaNodeTemplate.class, name, version);
-
- automationCompositionProvider
- .deleteInstanceProperties(automationCompositionProvider.saveInstanceProperties(toscaServiceTest), filtered);
-
- verify(toscaNodeTemplateRepository).delete(any());
- }
-
- @Test
void testGetNodeTemplates() {
var toscaNodeTemplateRepository = mock(ToscaNodeTemplateRepository.class);
var automationCompositionProvider =
- new AutomationCompositionProvider(mock(AutomationCompositionRepository.class), toscaNodeTemplateRepository,
- mock(ToscaNodeTemplatesRepository.class));
+ new AutomationCompositionProvider(mock(AutomationCompositionRepository.class), toscaNodeTemplateRepository);
var toscaNodeTemplate0 = new JpaToscaNodeTemplate(new PfConceptKey(ID_NAME, ID_VERSION));
var toscaNodeTemplate1 = new JpaToscaNodeTemplate(new PfConceptKey("PMSHInstance2", ID_VERSION));
@@ -287,14 +241,4 @@ class AutomationCompositionProviderTest {
assertThatThrownBy(() -> automationCompositionProvider.getFilteredNodeTemplates(null))
.hasMessageMatching("filter is marked non-null but is null");
}
-
- private static ToscaServiceTemplate testAutomationCompositionRead() {
- return testAutomationCompositionYamlSerialization();
- }
-
- private static ToscaServiceTemplate testAutomationCompositionYamlSerialization() {
- var automationCompositionString = ResourceUtils.getResourceAsString(
- AutomationCompositionProviderTest.TOSCA_TEMPLATE_YAML);
- return yamlTranslator.fromYaml(automationCompositionString, ToscaServiceTemplate.class);
- }
}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ServiceTemplateProviderTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ServiceTemplateProviderTest.java
index aa95a79d4..9e4133da5 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ServiceTemplateProviderTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ServiceTemplateProviderTest.java
@@ -65,21 +65,6 @@ class ServiceTemplateProviderTest {
}
@Test
- void testGetDerivedCommonOrInstanceNodeTemplates() throws PfModelException {
- var serviceTemplateRepository = mock(ToscaServiceTemplateRepository.class);
- var serviceTemplateProvider = new ServiceTemplateProvider(serviceTemplateRepository);
-
- var commonOrInstanceNodeTypeProps =
- serviceTemplateProvider.getCommonOrInstancePropertiesFromNodeTypes(true, inputServiceTemplate);
-
- var result = serviceTemplateProvider.getDerivedCommonOrInstanceNodeTemplates(
- inputServiceTemplate.getToscaTopologyTemplate().getNodeTemplates(), commonOrInstanceNodeTypeProps);
-
- assertNotNull(result);
- assertThat(result).hasSize(4);
- }
-
- @Test
void testCreateServiceTemplate() throws PfModelException {
var serviceTemplateRepository = mock(ToscaServiceTemplateRepository.class);
var serviceTemplateProvider = new ServiceTemplateProvider(serviceTemplateRepository);