diff options
author | andre.schmid <andre.schmid@est.tech> | 2020-01-29 17:25:21 +0000 |
---|---|---|
committer | Ofir Sonsino <ofir.sonsino@intl.att.com> | 2020-04-19 16:35:32 +0000 |
commit | cd6f933375c412c2f79a12e909821322d58a8499 (patch) | |
tree | 758ff2e742b514169bbc84a8433d68fe221ef5c9 /catalog-model/src/test/java | |
parent | dc56692a4a307f378c827f017d2efbf754c223e0 (diff) |
Configure a new Artifact Type
Centralizes artifact configuration in one yaml entry.
Allow the configuration of a new artifact type without
the need of code changes.
The configuration file now is used as a source of
artifacts types instead the artifact type enum.
The enum will be used as a source of base artifact types
and also in hard coded business rules.
Change-Id: Id0383d9fca9bce0519a4d52a4ecb3a68c8713f0f
Issue-ID: SDC-2754
Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-model/src/test/java')
-rw-r--r-- | catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java | 96 |
1 files changed, 33 insertions, 63 deletions
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java index 17e2430d82..3597d02834 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java @@ -25,6 +25,7 @@ import org.apache.tinkerpop.gremlin.structure.T; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; +import org.openecomp.sdc.be.config.ArtifactConfiguration; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphGenericDao; @@ -47,6 +48,7 @@ import java.util.List; import java.util.Map; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @RunWith(SpringJUnit4ClassRunner.class) @@ -64,52 +66,44 @@ public class ElementOperationTest extends ModelTestBase { @BeforeClass public static void setupBeforeClass() { - // ExternalConfiguration.setAppName("catalog-model"); - // String appConfigDir = "src/test/resources/config/catalog-model"; - // ConfigurationSource configurationSource = new - // FSConfigurationSource(ExternalConfiguration.getChangeListener(), - // appConfigDir); - ModelTestBase.init(); - } @Test public void testGetArtifactsTypes() { - - List<String> artifactTypesCfg = new ArrayList<>(); - artifactTypesCfg.add("type1"); - artifactTypesCfg.add("type2"); - artifactTypesCfg.add("type3"); - artifactTypesCfg.add("type4"); - configurationManager.getConfiguration().setArtifactTypes(artifactTypesCfg); - Either<List<ArtifactType>, ActionStatus> allArtifactTypes = elementOperation.getAllArtifactTypes(); - assertTrue(allArtifactTypes.isLeft()); - assertEquals(artifactTypesCfg.size(), allArtifactTypes.left().value().size()); - - artifactTypesCfg.remove(0); - allArtifactTypes = elementOperation.getAllArtifactTypes(); - assertTrue(allArtifactTypes.isLeft()); - assertEquals(artifactTypesCfg.size(), allArtifactTypes.left().value().size()); - - artifactTypesCfg.add("type5"); + final List<ArtifactConfiguration> expectedArtifactConfigurationList = new ArrayList<>(); + final ArtifactConfiguration artifactConfiguration1 = new ArtifactConfiguration(); + artifactConfiguration1.setType("type1"); + expectedArtifactConfigurationList.add(artifactConfiguration1); + final ArtifactConfiguration artifactConfiguration2 = new ArtifactConfiguration(); + artifactConfiguration2.setType("type2"); + expectedArtifactConfigurationList.add(artifactConfiguration2); + final ArtifactConfiguration artifactConfiguration3 = new ArtifactConfiguration(); + artifactConfiguration3.setType("type3"); + expectedArtifactConfigurationList.add(artifactConfiguration3); + configurationManager.getConfiguration().setArtifacts(expectedArtifactConfigurationList); + + List<ArtifactType> actualArtifactTypes = elementOperation.getAllArtifactTypes(); + assertNotNull(actualArtifactTypes); + assertEquals(expectedArtifactConfigurationList.size(), actualArtifactTypes.size()); + boolean allMatch = actualArtifactTypes.stream().allMatch(artifactType -> + expectedArtifactConfigurationList.stream() + .anyMatch(artifactConfiguration -> artifactConfiguration.getType().equals(artifactType.getName())) + ); + assertTrue(allMatch); + + expectedArtifactConfigurationList.remove(0); + actualArtifactTypes = elementOperation.getAllArtifactTypes(); + assertNotNull(actualArtifactTypes); + assertEquals(expectedArtifactConfigurationList.size(), actualArtifactTypes.size()); + + allMatch = actualArtifactTypes.stream().allMatch(artifactType -> + expectedArtifactConfigurationList.stream() + .anyMatch(artifactConfiguration -> artifactConfiguration.getType().equals(artifactType.getName())) + ); + assertTrue(allMatch); } - @Test - public void testAllDeploymentArtifactTypes() { - - List<String> artifactTypesCfg = new ArrayList<String>(); - artifactTypesCfg.add("type1"); - artifactTypesCfg.add("type2"); - artifactTypesCfg.add("type3"); - configurationManager.getConfiguration().setArtifactTypes(artifactTypesCfg); - Either<Map<String, Object>, ActionStatus> allDeploymentArtifactTypes = elementOperation - .getAllDeploymentArtifactTypes(); - assertTrue(allDeploymentArtifactTypes.isLeft()); - assertEquals(artifactTypesCfg.size(), allDeploymentArtifactTypes.left().value().size()); - - } - // @Test public void testGetResourceAndServiceCategoty() { String id = OperationTestsUtil.deleteAndCreateResourceCategory(CATEGORY, SUBCATEGORY, janusGraphDao); @@ -431,29 +425,6 @@ public class ElementOperationTest extends ModelTestBase { testSubject = createTestSubject(); result = testSubject.getAllPropertyScopes(); } - - - @Test - public void testGetAllArtifactTypes() throws Exception { - ElementOperation testSubject; - Either<List<ArtifactType>, ActionStatus> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getAllArtifactTypes(); - } - - - @Test - public void testGetAllDeploymentArtifactTypes() throws Exception { - ElementOperation testSubject; - Either<Map<String, Object>, ActionStatus> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getAllDeploymentArtifactTypes(); - } - @Test public void testGetResourceTypesMap() throws Exception { @@ -465,7 +436,6 @@ public class ElementOperationTest extends ModelTestBase { result = testSubject.getResourceTypesMap(); } - @Test public void testGetNewCategoryData() throws Exception { ElementOperation testSubject; |