aboutsummaryrefslogtreecommitdiffstats
path: root/asdctool/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'asdctool/src/test')
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/UtilsTest.java2
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/cli/CLIToolTest.java10
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/cli/SpringCLIToolTest.java61
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/configuration/ArtifactUUIDFixConfigurationTest.java19
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/configuration/GetConsumersConfigurationTest.java43
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/configuration/mocks/es/ESCatalogDAOMockTest.java97
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/configuration/mocks/es/ElasticSearchClientMockTest.java69
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/configuration/mocks/es/ElasticSearchMocksConfigurationTest.java63
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/configuration/mocks/es/EsHealthCheckDaoMockTest.java41
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFixTest.java28
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ComponentInstanceRowTest.java4
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ComponentRowTest.java4
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/DataMigrationTest.java371
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/EsToCassandraDataMigrationConfigTest.java90
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/GraphJsonValidatorTest.java6
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/GraphMLConverterTest.java2
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ProductLogicTest.java3
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/VrfObjectFixHandlerTest.java2
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/internal/tool/CsarGeneratorTest.java37
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/internal/tool/DeleteComponentHandlerTest.java3
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBLTest.java10
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBLTest.java9
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java18
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecuterTest.java8
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecuterTest.java4
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutorTest.java4
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuterTest.java4
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuterTest.java4
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutorTest.java4
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuterTest.java9
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtilsTest.java36
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTaskTest.java5
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTaskTest.java4
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerHelper.java4
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerTest.java22
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/main/ExportImportMenuTest.java272
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/config/MigrationSpringConfigTest.java10
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/core/SdcMigrationToolTest.java4
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/scanner/ClassScanner.java6
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/service/SdcRepoServiceTest.java15
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/task/MigrationTasksTest.java6
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/handlers/XlsOutputHandlerTest.java4
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1710/UpgradeMigration1710Test.java24
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1802/SdcCatalogMigrationTest.java2
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/ForwardPathMigrationTest.java6
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/ResourceLifecycleMigrationTest.java6
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/SDCInstancesMigrationTest.java9
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/SdcArchiveMigrationTest.java6
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1902/SdcGroupsMigrationTest.java231
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1902/SdcResourceIconMigrationTest.java213
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/utils/ReportWriterTest.java1
51 files changed, 636 insertions, 1279 deletions
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/UtilsTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/UtilsTest.java
index 6193e7e27c..017126e86b 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/UtilsTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/UtilsTest.java
@@ -20,9 +20,9 @@
package org.openecomp.sdc.asdctool;
-import org.janusgraph.core.JanusGraph;
import org.apache.commons.configuration.Configuration;
import org.apache.tinkerpop.gremlin.structure.Element;
+import org.janusgraph.core.JanusGraph;
import org.junit.Assert;
import org.junit.Test;
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/cli/CLIToolTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/cli/CLIToolTest.java
index 6c15b61a4e..9a5a8b3d9e 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/cli/CLIToolTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/cli/CLIToolTest.java
@@ -21,17 +21,17 @@
package org.openecomp.sdc.asdctool.cli;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionGroup;
import org.apache.commons.cli.Options;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
public class CLIToolTest {
private static final String OPT = "t";
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/cli/SpringCLIToolTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/cli/SpringCLIToolTest.java
deleted file mode 100644
index c91a694918..0000000000
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/cli/SpringCLIToolTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP SDC
- * ================================================================================
- * Copyright (C) 2019 Samsung. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- */
-
-package org.openecomp.sdc.asdctool.cli;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-import org.springframework.context.annotation.Configuration;
-
-public class SpringCLIToolTest {
-
- private static final String DIR_NAME = "test-dir";
-
- private SpringCLITool impl = new SpringCLIToolImplTest();
-
- @Test
- public void testInit() {
- // when
- final CLIToolData init = impl.init(new String[]{"-c", DIR_NAME});
-
- // then
- assertEquals(DIR_NAME, init.getCommandLine().getOptionValue("c"));
- assertTrue(init.getSpringApplicationContext().containsBean("config"));
- }
-
- private static class SpringCLIToolImplTest extends SpringCLITool {
- @Override
- protected Class<?> getSpringConfigurationClass() {
- return Config.class;
- }
-
- @Override
- protected String commandName() {
- return "run";
- }
- }
-}
-
-@Configuration
-class Config {
-}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/configuration/ArtifactUUIDFixConfigurationTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/configuration/ArtifactUUIDFixConfigurationTest.java
index 1ee1c4a700..bc1c87d398 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/configuration/ArtifactUUIDFixConfigurationTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/configuration/ArtifactUUIDFixConfigurationTest.java
@@ -20,8 +20,6 @@
package org.openecomp.sdc.asdctool.configuration;
-import static org.mockito.Mockito.mock;
-
import org.junit.Test;
import org.openecomp.sdc.asdctool.impl.ArtifactUuidFix;
import org.openecomp.sdc.be.components.distribution.engine.ServiceDistributionArtifactsBuilder;
@@ -30,7 +28,8 @@ import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.tosca.CsarUtils;
import org.openecomp.sdc.be.tosca.ToscaExportHandler;
-import org.springframework.beans.factory.config.PropertiesFactoryBean;
+
+import static org.mockito.Mockito.mock;
public class ArtifactUUIDFixConfigurationTest {
@@ -38,6 +37,9 @@ public class ArtifactUUIDFixConfigurationTest {
return new ArtifactUUIDFixConfiguration();
}
+ private static ToscaExportHandler toscaExportHandler;
+ private static CsarUtils csarUtils;
+
@Test
public void testArtifactUuidFix() throws Exception {
ArtifactUUIDFixConfiguration testSubject;
@@ -47,9 +49,7 @@ public class ArtifactUUIDFixConfigurationTest {
testSubject = createTestSubject();
JanusGraphDao janusGraphDao = mock(JanusGraphDao.class);
ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class);
- ToscaExportHandler toscaExportHandler = mock(ToscaExportHandler.class);
ArtifactCassandraDao artifactCassandraDao = mock(ArtifactCassandraDao.class);
- CsarUtils csarUtils = mock(CsarUtils.class);
result = testSubject.artifactUuidFix(janusGraphDao, toscaOperationFacade,
toscaExportHandler, artifactCassandraDao, csarUtils);
@@ -64,13 +64,4 @@ public class ArtifactUUIDFixConfigurationTest {
testSubject = createTestSubject();
}
- @Test
- public void testMapper() throws Exception {
- ArtifactUUIDFixConfiguration testSubject;
- PropertiesFactoryBean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.mapper();
- }
}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/configuration/GetConsumersConfigurationTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/configuration/GetConsumersConfigurationTest.java
deleted file mode 100644
index cbc9d37ca1..0000000000
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/configuration/GetConsumersConfigurationTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.configuration;
-
-import org.junit.Test;
-import org.openecomp.sdc.be.dao.janusgraph.JanusGraphGenericDao;
-import org.openecomp.sdc.be.model.operations.impl.ConsumerOperation;
-
-public class GetConsumersConfigurationTest {
-
- private GetConsumersConfiguration createTestSubject() {
- return new GetConsumersConfiguration();
- }
-
- @Test
- public void testConsumerOperation() throws Exception {
- GetConsumersConfiguration testSubject;
- JanusGraphGenericDao janusGraphGenericDao = null;
- ConsumerOperation result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.consumerOperation(janusGraphGenericDao);
- }
-}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/configuration/mocks/es/ESCatalogDAOMockTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/configuration/mocks/es/ESCatalogDAOMockTest.java
deleted file mode 100644
index 42713d7248..0000000000
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/configuration/mocks/es/ESCatalogDAOMockTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.configuration.mocks.es;
-
-import fj.data.Either;
-import org.junit.Test;
-import org.openecomp.sdc.be.dao.api.ResourceUploadStatus;
-import org.openecomp.sdc.be.resources.data.ESArtifactData;
-
-import java.util.List;
-
-public class ESCatalogDAOMockTest {
-
- private ESCatalogDAOMock createTestSubject() {
- return new ESCatalogDAOMock();
- }
-
- @Test
- public void testAddToIndicesMap() throws Exception {
- ESCatalogDAOMock testSubject;
- String typeName = "";
- String indexName = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.addToIndicesMap(typeName, indexName);
- }
-
- @Test
- public void testWriteArtifact() throws Exception {
- ESCatalogDAOMock testSubject;
- ESArtifactData artifactData = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.writeArtifact(artifactData);
- }
-
- @Test
- public void testGetArtifact() throws Exception {
- ESCatalogDAOMock testSubject;
- String id = "";
- Either<ESArtifactData, ResourceUploadStatus> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getArtifact(id);
- }
-
- @Test
- public void testGetArtifacts() throws Exception {
- ESCatalogDAOMock testSubject;
- String[] ids = new String[] { "" };
- Either<List<ESArtifactData>, ResourceUploadStatus> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getArtifacts(ids);
- }
-
- @Test
- public void testDeleteArtifact() throws Exception {
- ESCatalogDAOMock testSubject;
- String id = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.deleteArtifact(id);
- }
-
- @Test
- public void testDeleteAllArtifacts() throws Exception {
- ESCatalogDAOMock testSubject;
-
- // default test
- testSubject = createTestSubject();
- testSubject.deleteAllArtifacts();
- }
-}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/configuration/mocks/es/ElasticSearchClientMockTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/configuration/mocks/es/ElasticSearchClientMockTest.java
deleted file mode 100644
index 6c589fc482..0000000000
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/configuration/mocks/es/ElasticSearchClientMockTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.configuration.mocks.es;
-
-import org.junit.Test;
-
-public class ElasticSearchClientMockTest {
-
- private ElasticSearchClientMock createTestSubject() {
- return new ElasticSearchClientMock();
- }
-
- @Test
- public void testInitialize() throws Exception {
- ElasticSearchClientMock testSubject;
-
- // default test
- testSubject = createTestSubject();
- testSubject.initialize();
- }
-
- @Test
- public void testSetClusterName() throws Exception {
- ElasticSearchClientMock testSubject;
- String clusterName = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setClusterName(clusterName);
- }
-
- @Test
- public void testSetLocal() throws Exception {
- ElasticSearchClientMock testSubject;
- String strIsLocal = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setLocal(strIsLocal);
- }
-
- @Test
- public void testSetTransportClient() throws Exception {
- ElasticSearchClientMock testSubject;
- String strIsTransportclient = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setTransportClient(strIsTransportclient);
- }
-}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/configuration/mocks/es/ElasticSearchMocksConfigurationTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/configuration/mocks/es/ElasticSearchMocksConfigurationTest.java
deleted file mode 100644
index 868e1e270a..0000000000
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/configuration/mocks/es/ElasticSearchMocksConfigurationTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.configuration.mocks.es;
-
-import org.junit.Test;
-import org.openecomp.sdc.be.dao.api.ICatalogDAO;
-import org.openecomp.sdc.be.dao.api.IEsHealthCheckDao;
-import org.openecomp.sdc.be.dao.es.ElasticSearchClient;
-
-public class ElasticSearchMocksConfigurationTest {
-
- private ElasticSearchMocksConfiguration createTestSubject() {
- return new ElasticSearchMocksConfiguration();
- }
-
- @Test
- public void testElasticSearchClientMock() throws Exception {
- ElasticSearchMocksConfiguration testSubject;
- ElasticSearchClient result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.elasticSearchClientMock();
- }
-
- @Test
- public void testEsCatalogDAOMock() throws Exception {
- ElasticSearchMocksConfiguration testSubject;
- ICatalogDAO result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.esCatalogDAOMock();
- }
-
- @Test
- public void testEsHealthCheckDaoMock() throws Exception {
- ElasticSearchMocksConfiguration testSubject;
- IEsHealthCheckDao result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.esHealthCheckDaoMock();
- }
-}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/configuration/mocks/es/EsHealthCheckDaoMockTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/configuration/mocks/es/EsHealthCheckDaoMockTest.java
deleted file mode 100644
index bd874c5ded..0000000000
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/configuration/mocks/es/EsHealthCheckDaoMockTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.configuration.mocks.es;
-
-import org.junit.Test;
-import org.openecomp.sdc.common.api.HealthCheckInfo.HealthCheckStatus;
-
-public class EsHealthCheckDaoMockTest {
-
- private EsHealthCheckDaoMock createTestSubject() {
- return new EsHealthCheckDaoMock();
- }
-
- @Test
- public void testGetClusterHealthStatus() throws Exception {
- EsHealthCheckDaoMock testSubject;
- HealthCheckStatus result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getClusterHealthStatus();
- }
-}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFixTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFixTest.java
index 0ea4484ba4..8d599e587a 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFixTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFixTest.java
@@ -20,8 +20,8 @@
package org.openecomp.sdc.asdctool.impl;
-import org.janusgraph.core.JanusGraphVertex;
import fj.data.Either;
+import org.janusgraph.core.JanusGraphVertex;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentMatchers;
@@ -40,16 +40,26 @@ import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.*;
+import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentParametersView;
+import org.openecomp.sdc.be.model.DistributionStatusEnum;
+import org.openecomp.sdc.be.model.GroupDefinition;
+import org.openecomp.sdc.be.model.GroupInstance;
+import org.openecomp.sdc.be.model.LifecycleStateEnum;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
-import org.openecomp.sdc.be.resources.data.ESArtifactData;
+import org.openecomp.sdc.be.resources.data.DAOArtifactData;
import org.openecomp.sdc.common.api.ArtifactTypeEnum;
import org.openecomp.sdc.common.api.Constants;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.ArrayList;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
@@ -185,11 +195,13 @@ public class ArtifactUuidFixTest {
.getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, hasProps, hasNotProps, JsonParseFlagEnum.ParseAll)).thenReturn(Either.left(list));
when(toscaOperationFacade.getToscaElement(ArgumentMatchers.eq(graphVertex.getUniqueId()),any(ComponentParametersView.class)))
.thenReturn(Either.left(service));
- byte[] payload = "value".getBytes();
- ESArtifactData esArtifactData =new ESArtifactData();
- esArtifactData.setDataAsArray(payload);
- Either<ESArtifactData, CassandraOperationStatus> artifactfromESres = Either.left(esArtifactData);
+ DAOArtifactData artifactData = new DAOArtifactData();
+ byte[] data = "value".getBytes();
+ ByteBuffer bufferData = ByteBuffer.wrap(data);
+ artifactData.setData(bufferData);
+
+ Either<DAOArtifactData, CassandraOperationStatus> artifactfromESres = Either.left(artifactData);
when(artifactCassandraDao.getArtifact(anyString())).thenReturn(artifactfromESres);
result = test.doFix(fixComponent, runMode);
assertEquals(false, result);
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ComponentInstanceRowTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ComponentInstanceRowTest.java
index 8b8f9893f6..184bc332d3 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ComponentInstanceRowTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ComponentInstanceRowTest.java
@@ -19,11 +19,11 @@
*/
package org.openecomp.sdc.asdctool.impl;
+import org.junit.Test;
+
import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
import static org.junit.Assert.assertThat;
-import org.junit.Test;
-
public class ComponentInstanceRowTest {
@Test
public void shouldHaveValidGettersAndSetters() {
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ComponentRowTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ComponentRowTest.java
index e5c139c698..fb78a4e294 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ComponentRowTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ComponentRowTest.java
@@ -19,11 +19,11 @@
*/
package org.openecomp.sdc.asdctool.impl;
+import org.junit.Test;
+
import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
import static org.junit.Assert.assertThat;
-import org.junit.Test;
-
public class ComponentRowTest {
@Test
public void shouldHaveValidGettersAndSetters() {
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/DataMigrationTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/DataMigrationTest.java
deleted file mode 100644
index 3472721dc6..0000000000
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/DataMigrationTest.java
+++ /dev/null
@@ -1,371 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-/*
-
- * Copyright (c) 2018 AT&T Intellectual Property.
-
- *
-
- * Licensed under the Apache License, Version 2.0 (the "License");
-
- * you may not use this file except in compliance with the License.
-
- * You may obtain a copy of the License at
-
- *
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- *
-
- * Unless required by applicable law or agreed to in writing, software
-
- * distributed under the License is distributed on an "AS IS" BASIS,
-
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-
- * See the License for the specific language governing permissions and
-
- * limitations under the License.
-
- */
-package org.openecomp.sdc.asdctool.impl;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao;
-import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao;
-import org.openecomp.sdc.be.dao.cassandra.schema.Table;
-import org.openecomp.sdc.be.resources.data.auditing.*;
-import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
-
-import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.openecomp.sdc.common.datastructure.AuditingFieldsKey.*;
-
-@RunWith(MockitoJUnitRunner.class)
-public class DataMigrationTest {
- private final static String DESCRIPTION = "OK";
- private final static String STATUS = "200";
- private final static String SERVICE_INSTANCE_ID = "SERVICE_INSTANCE_ID";
- private final static String MODIFIER = "MODIFIER";
- private final static String REQUEST_ID = "REQUEST_ID";
- private final static String USER = "USER";
- private final static String USER_BEFORE = "USER_BEFORE";
- private final static String USER_AFTER = "USER_AFTER";
- private final static String ARTIFACT_UUID = "ARTIFACT_UUID";
-
- private final static String PREV_STATE = "PREV_STATE";
- private final static String CURR_STATE = "CURR_STATE";
- private final static String PREV_VERSION = "PREV_VERSION";
- private final static String CURR_VERSION = "CURR_VERSION";
- private final static String DPREV_STATUS = "DPREV_STATUS";
- private final static String DCURR_STATUS = "CURR_STATUS";
- private final static String INVARIANT_UUID = "INVARIANT_UUID";
- private final static String ARTIFACT_DATA = "ARTIFACT_DATA";
- private final static String COMMENT = "COMMENT";
- private final static String DISTRIBUTION_ID = "DISTRIBUTION_ID";
- private final static String TOSCA_NODE_TYPE = "TOSCA_NODE_TYPE";
- private final static String CONSUMER_ID = "CONSUMER_ID";
- private final static String RESOURCE_URL = "RESOURCE_URL";
- private final static String ENV_ID = "ENV_ID";
- private final static String VNF_WORKLOAD_CONTEXT = "VNF_WORKLOAD_CONTEXT";
- private final static String TENANT = "TENANT";
- private final static String RESOURCE_NAME = "RESOURCE_NAME";
- private final static String RESOURCE_TYPE = "RESOURCE_TYPE";
- private final static String AUTH_URL = "AUTH_URL";
- private final static String AUTH_RELM = "AUTH_RELM";
- private final static String TOPIC_NAME = "TOPIC_NAME";
-
- private final static String dateFormatPattern = "yyyy-MM-dd HH:mm:ss.SSS z";
-
- private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern);
-
- private static ArtifactCassandraDao artifactCassandraDao = mock(ArtifactCassandraDao.class);
-
- private static AuditCassandraDao auditCassandraDaoMock = mock(AuditCassandraDao.class);
-
- private static DataMigration dataMigration = new DataMigration(auditCassandraDaoMock, artifactCassandraDao);
-
- private final static String ES_STRING = "{\"" + AuditingFieldsKey.AUDIT_ACTION + "\":\"%s\", \"" + AuditingFieldsKey.AUDIT_RESOURCE_NAME + "\":\"" + RESOURCE_NAME + "\", \"" + AuditingFieldsKey.AUDIT_RESOURCE_TOSCA_NODE_TYPE + "\":\"" + TOSCA_NODE_TYPE +
- "\", \"" + AuditingFieldsKey.AUDIT_RESOURCE_PREV_VERSION + "\":\"" + PREV_VERSION + "\", \"" + AuditingFieldsKey.AUDIT_RESOURCE_PREV_STATE + "\":\"" + PREV_STATE +
- "\", \"" + AuditingFieldsKey.AUDIT_RESOURCE_TYPE + "\":\"" + RESOURCE_TYPE + "\", \"" + AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID + "\":\"" + SERVICE_INSTANCE_ID +
- "\", \"" + AuditingFieldsKey.AUDIT_INVARIANT_UUID + "\":\"" + INVARIANT_UUID + "\", \"" + AuditingFieldsKey.AUDIT_RESOURCE_CURR_VERSION + "\":\"" + CURR_VERSION +
- "\", \"" + AuditingFieldsKey.AUDIT_RESOURCE_CURR_STATE + "\":\"" + CURR_STATE + "\", \"" + AuditingFieldsKey.AUDIT_MODIFIER_UID + "\":\"" + MODIFIER +
- "\", \"" + AuditingFieldsKey.AUDIT_DESC + "\":\"" + DESCRIPTION + "\", \"" + AuditingFieldsKey.AUDIT_STATUS + "\":\"" + STATUS +
- "\", \"" + AuditingFieldsKey.AUDIT_REQUEST_ID + "\":\"" + REQUEST_ID + "\", \"" + AuditingFieldsKey.AUDIT_CURR_ARTIFACT_UUID + "\":\"" + ARTIFACT_UUID +
- "\", \"" + AuditingFieldsKey.AUDIT_PREV_ARTIFACT_UUID + "\":\"" + ARTIFACT_UUID + "\", \"" + AuditingFieldsKey.AUDIT_ARTIFACT_DATA + "\":\"" + ARTIFACT_DATA +
- "\", \"" + AuditingFieldsKey.AUDIT_TIMESTAMP + "\":\"%s\"}";
-
-
- private String timestampStr;
-
- private HashMap<AuditingFieldsKey, String> dataMap = new HashMap<>();
-
- @Before
- public void setUp() {
- dataMap.put(AUDIT_DESC, DESCRIPTION);
- dataMap.put(AUDIT_STATUS, STATUS);
- dataMap.put(AUDIT_REQUEST_ID, REQUEST_ID);
- dataMap.put(AUDIT_SERVICE_INSTANCE_ID, SERVICE_INSTANCE_ID);
- dataMap.put(AUDIT_MODIFIER_UID, MODIFIER);
- dataMap.put(AUDIT_USER_BEFORE, USER_BEFORE);
- dataMap.put(AUDIT_USER_UID, USER);
- dataMap.put(AUDIT_USER_AFTER, USER_AFTER);
- dataMap.put(AUDIT_AUTH_URL, AUTH_URL);
- dataMap.put(AUDIT_AUTH_REALM, AUTH_RELM);
- dataMap.put(AUDIT_PREV_ARTIFACT_UUID, ARTIFACT_UUID);
- dataMap.put(AUDIT_CURR_ARTIFACT_UUID, ARTIFACT_UUID);
- dataMap.put(AUDIT_RESOURCE_PREV_STATE, PREV_STATE);
- dataMap.put(AUDIT_RESOURCE_PREV_VERSION, PREV_VERSION);
- dataMap.put(AUDIT_RESOURCE_CURR_STATE, CURR_STATE);
- dataMap.put(AUDIT_RESOURCE_CURR_VERSION, CURR_VERSION);
- dataMap.put(AUDIT_RESOURCE_DPREV_STATUS, DPREV_STATUS);
- dataMap.put(AUDIT_RESOURCE_DCURR_STATUS, DCURR_STATUS);
- dataMap.put(AUDIT_INVARIANT_UUID, INVARIANT_UUID);
- dataMap.put(AUDIT_ARTIFACT_DATA, ARTIFACT_DATA);
- dataMap.put(AUDIT_RESOURCE_COMMENT, COMMENT);
- dataMap.put(AUDIT_DISTRIBUTION_ID, DISTRIBUTION_ID);
- dataMap.put(AUDIT_RESOURCE_TOSCA_NODE_TYPE, TOSCA_NODE_TYPE);
- dataMap.put(AUDIT_DISTRIBUTION_CONSUMER_ID, CONSUMER_ID);
- dataMap.put(AUDIT_RESOURCE_URL, RESOURCE_URL);
- dataMap.put(AUDIT_DISTRIBUTION_ENVIRONMENT_ID, ENV_ID);
- dataMap.put(AUDIT_DISTRIBUTION_VNF_WORKLOAD_CONTEXT, VNF_WORKLOAD_CONTEXT);
- dataMap.put(AUDIT_DISTRIBUTION_TENANT, TENANT);
- dataMap.put(AUDIT_RESOURCE_NAME, RESOURCE_NAME);
- dataMap.put(AUDIT_RESOURCE_TYPE, RESOURCE_TYPE);
- timestampStr = simpleDateFormat.format(new Date());
- dataMap.put(AUDIT_TIMESTAMP, timestampStr);
- dataMap.put(AUDIT_DISTRIBUTION_TOPIC_NAME, TOPIC_NAME);
-
- }
-
- @Test
- public void createUserAdminEvent() {
- dataMap.put(AUDIT_ACTION, AuditingActionEnum.ADD_USER.getName());
- AuditingGenericEvent event = dataMigration.createAuditEvent(dataMap, Table.USER_ADMIN_EVENT);
- assertThat(AuditingActionEnum.ADD_USER.getName()).isEqualTo(event.getAction());
- verifyCommonData(event, true);
- verifyUserAdminEvent((UserAdminEvent) event);
- }
-
- @Test
- public void createResourceAdminEvent() {
- dataMap.put(AUDIT_ACTION, AuditingActionEnum.UPDATE_RESOURCE_METADATA.getName());
- AuditingGenericEvent event = dataMigration.createAuditEvent(dataMap, Table.RESOURCE_ADMIN_EVENT);
- assertThat(AuditingActionEnum.UPDATE_RESOURCE_METADATA.getName()).isEqualTo(event.getAction());
- verifyCommonData(event, true);
- verifyResourceAdminEvent((ResourceAdminEvent)event);
- }
-
- @Test
- public void createDistributionNotificationEvent() {
- dataMap.put(AUDIT_ACTION, AuditingActionEnum.DISTRIBUTION_NOTIFY.getName());
- AuditingGenericEvent event = dataMigration.createAuditEvent(dataMap, Table.DISTRIBUTION_NOTIFICATION_EVENT);
- assertThat(AuditingActionEnum.DISTRIBUTION_NOTIFY.getName()).isEqualTo(event.getAction());
- verifyCommonData(event, true);
- verifyDistributionNotificationEvent((DistributionNotificationEvent)event);
- }
-
- @Test
- public void createEventWhenSomeFieldValuesNotSet() {
- dataMap.clear();
- dataMap.put(AUDIT_ACTION, AuditingActionEnum.AUTH_REQUEST.getName());
- AuditingGenericEvent event = dataMigration.createAuditEvent(dataMap, Table.AUTH_EVENT);
- assertThat(AuditingActionEnum.AUTH_REQUEST.getName()).isEqualTo(event.getAction());
- assertThat(event.getStatus()).isNull();
- assertThat(event.getDesc()).isNull();
- assertThat(event.getRequestId()).isNull();
- }
-
- @Test
- public void createAuthEvent() {
- dataMap.put(AUDIT_ACTION, AuditingActionEnum.AUTH_REQUEST.getName());
- AuditingGenericEvent event = dataMigration.createAuditEvent(dataMap, Table.AUTH_EVENT);
- assertThat(AuditingActionEnum.AUTH_REQUEST.getName()).isEqualTo(event.getAction());
- verifyCommonData(event, false);
- verifyAuthEvent((AuthEvent) event);
- }
-
- @Test
- public void createImportResourceEventFromEsObject() throws IOException{
- AuditingGenericEvent event = dataMigration.createAuditRecordForCassandra(String.format(ES_STRING, AuditingActionEnum.IMPORT_RESOURCE.getName(), timestampStr), Table.RESOURCE_ADMIN_EVENT);
- assertThat(AuditingActionEnum.IMPORT_RESOURCE.getName()).isEqualTo(event.getAction());
- verifyCommonData(event, true);
- verifyResourceAdminEvent((ResourceAdminEvent)event);
- }
-
- @Test
- public void createGetUserListEventFromEsObject() throws IOException{
- AuditingGenericEvent event = dataMigration.createAuditRecordForCassandra(String.format(ES_STRING, AuditingActionEnum.GET_USERS_LIST.getName(), timestampStr),
- Table.GET_USERS_LIST_EVENT);
- assertThat(AuditingActionEnum.GET_USERS_LIST.getName()).isEqualTo(event.getAction());
- verifyCommonData(event, false);
- assertThat(((GetUsersListEvent)event).getModifier()).isEqualTo(MODIFIER);
- }
-
- @Test
- public void createEventFromEsFailedWhenActionDoesNotExist() throws IOException {
- dataMigration.createAuditRecordForCassandra(String.format(ES_STRING, AuditingActionEnum.IMPORT_RESOURCE.getName(), timestampStr),
- Table.CONSUMER_EVENT);
- }
-
- @Test(expected = NullPointerException.class)
- public void createRecordWhenJsonIsEmpty() throws IOException{
- dataMigration.createAuditRecordForCassandra("{}",
- Table.CONSUMER_EVENT);
- }
-
- @Test
- public void createEventFromUEBCluster() throws IOException
- {
- AuditingGenericEvent event = dataMigration.createAuditRecordForCassandra(String.format(ES_STRING, AuditingActionEnum.IMPORT_RESOURCE.getName(), timestampStr),
- Table.DISTRIBUTION_GET_UEB_CLUSTER_EVENT);
- assertThat(AuditingActionEnum.GET_UEB_CLUSTER.getName()).isEqualTo(event.getAction());
- verifyCommonData(event, true);
- }
-
- @Test
- public void createEventFromDistEngine() throws IOException
- {
- AuditingGenericEvent event = dataMigration.createAuditRecordForCassandra(String.format(ES_STRING, AuditingActionEnum.IMPORT_RESOURCE.getName(), timestampStr),
- Table.DISTRIBUTION_ENGINE_EVENT);
- assertThat(AuditingActionEnum.IMPORT_RESOURCE.getName()).isEqualTo(event.getAction());
- verifyCommonData(event, true);
- }
-
- @Test
- public void createEventFromDistStatus() throws IOException
- {
- AuditingGenericEvent event = dataMigration.createAuditRecordForCassandra(String.format(ES_STRING, AuditingActionEnum.IMPORT_RESOURCE.getName(), timestampStr),
- Table.DISTRIBUTION_STATUS_EVENT);
- assertThat(AuditingActionEnum.DISTRIBUTION_STATUS.getName()).isEqualTo(event.getAction());
- verifyCommonData(event, true);
- }
-
- @Test
- public void createEventFromCategory() throws IOException
- {
- AuditingGenericEvent event = dataMigration.createAuditRecordForCassandra(String.format(ES_STRING, AuditingActionEnum.IMPORT_RESOURCE.getName(), timestampStr),
- Table.CATEGORY_EVENT);
- assertThat(AuditingActionEnum.IMPORT_RESOURCE.getName()).isEqualTo(event.getAction());
- verifyCommonData(event, true);
- }
-
- @Test
- public void createFromCategoryHierarchy() throws IOException
- {
- AuditingGenericEvent event = dataMigration.createAuditRecordForCassandra(String.format(ES_STRING, AuditingActionEnum.IMPORT_RESOURCE.getName(), timestampStr),
- Table.GET_CATEGORY_HIERARCHY_EVENT);
- assertThat(AuditingActionEnum.GET_CATEGORY_HIERARCHY.getName()).isEqualTo(event.getAction());
- verifyCommonData(event, false);
- }
-
- @Test
- public void createEventFromUserAccess() throws IOException
- {
- AuditingGenericEvent event = dataMigration.createAuditRecordForCassandra(String.format(ES_STRING, AuditingActionEnum.IMPORT_RESOURCE.getName(), timestampStr),
- Table.USER_ACCESS_EVENT);
- assertThat(AuditingActionEnum.USER_ACCESS.getName()).isEqualTo(event.getAction());
- verifyCommonData(event, true);
- }
-
- @Test
- public void createEventFromDistDwnld() throws IOException
- {
- AuditingGenericEvent event = dataMigration.createAuditRecordForCassandra(String.format(ES_STRING, AuditingActionEnum.IMPORT_RESOURCE.getName(), timestampStr),
- Table.DISTRIBUTION_DOWNLOAD_EVENT);
- assertThat(AuditingActionEnum.DISTRIBUTION_ARTIFACT_DOWNLOAD.getName()).isEqualTo(event.getAction());
- verifyCommonData(event, true);
- }
-
- @Test
- public void createEventFromDistDeploy() throws IOException
- {
- AuditingGenericEvent event = dataMigration.createAuditRecordForCassandra(String.format(ES_STRING, AuditingActionEnum.IMPORT_RESOURCE.getName(), timestampStr),
- Table.DISTRIBUTION_DEPLOY_EVENT);
- assertThat(AuditingActionEnum.DISTRIBUTION_DEPLOY.getName()).isEqualTo(event.getAction());
- verifyCommonData(event, true);
- }
-
- private void verifyCommonData(AuditingGenericEvent event, boolean isServiceInstanceProvided) {
- assertThat(STATUS).isEqualTo(event.getStatus());
- if (isServiceInstanceProvided) {
- assertThat(SERVICE_INSTANCE_ID).isEqualTo(event.getServiceInstanceId());
- }
- else {
- assertThat(event.getServiceInstanceId()).isNull();
- }
- assertThat(DESCRIPTION).isEqualTo(event.getDesc());
- assertThat(REQUEST_ID).isEqualTo(event.getRequestId());
- }
-
- private void verifyUserAdminEvent(UserAdminEvent event) {
- assertThat(USER_AFTER).isEqualTo(event.getUserAfter());
- assertThat(USER_BEFORE).isEqualTo(event.getUserBefore());
- verifyTimestamp(event.getTimestamp1());
- }
-
- private void verifyAuthEvent(AuthEvent event) {
- assertThat(USER).isEqualTo(event.getUser());
- assertThat(AUTH_URL).isEqualTo(event.getUrl());
- assertThat(event.getAuthStatus()).isNull();
- assertThat(AUTH_RELM).isEqualTo(event.getRealm());
- }
-
- private void verifyTimestamp(Date date) {
- assertThat(timestampStr).isEqualTo(simpleDateFormat.format(date));
- }
-
- private void verifyResourceAdminEvent(ResourceAdminEvent event) {
- assertThat(CURR_STATE).isEqualTo(event.getCurrState());
- assertThat(CURR_VERSION).isEqualTo(event.getCurrVersion());
- assertThat(ARTIFACT_UUID).isEqualTo(event.getCurrArtifactUUID());
- assertThat(PREV_STATE).isEqualTo(event.getPrevState());
- assertThat(PREV_VERSION).isEqualTo(event.getPrevVersion());
- assertThat(ARTIFACT_UUID).isEqualTo(event.getPrevArtifactUUID());
- assertThat(INVARIANT_UUID).isEqualTo(event.getInvariantUUID());
- assertThat(ARTIFACT_DATA).isEqualTo(event.getArtifactData());
- assertThat(RESOURCE_NAME).isEqualTo(event.getResourceName());
- assertThat(RESOURCE_TYPE).isEqualTo(event.getResourceType());
- verifyTimestamp(event.getTimestamp1());
- assertThat(TOSCA_NODE_TYPE).isEqualTo( event.getToscaNodeType());
- }
-
- private void verifyDistributionNotificationEvent(DistributionNotificationEvent event) {
- assertThat(CURR_STATE).isEqualTo(event.getCurrState());
- assertThat(CURR_VERSION).isEqualTo(event.getCurrVersion());
- assertThat(TOPIC_NAME).isEqualTo(event.getTopicName());
- assertThat(DISTRIBUTION_ID).isEqualTo(event.getDid());
- assertThat(ENV_ID).isEqualTo(event.getEnvId());
- assertThat(VNF_WORKLOAD_CONTEXT).isEqualTo(event.getVnfWorkloadContext());
- assertThat(TENANT).isEqualTo(event.getTenant());
- verifyTimestamp(event.getTimestamp1());
- }
-
-}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/EsToCassandraDataMigrationConfigTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/EsToCassandraDataMigrationConfigTest.java
deleted file mode 100644
index f1f161b2db..0000000000
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/EsToCassandraDataMigrationConfigTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl;
-
-import static org.mockito.Mockito.mock;
-
-import org.junit.Test;
-import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao;
-import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao;
-import org.openecomp.sdc.be.dao.cassandra.CassandraClient;
-import org.openecomp.sdc.be.dao.cassandra.SdcSchemaFilesCassandraDao;
-
-import static org.mockito.Mockito.mock;
-
-public class EsToCassandraDataMigrationConfigTest {
-
- private EsToCassandraDataMigrationConfig createTestSubject() {
- return new EsToCassandraDataMigrationConfig();
- }
-
- @Test
- public void testDataMigration() throws Exception {
- EsToCassandraDataMigrationConfig testSubject;
- DataMigration result;
- AuditCassandraDao auditCassandraDaoMock = mock(AuditCassandraDao.class);
- ArtifactCassandraDao artifactCassandraDaoMock = mock(ArtifactCassandraDao.class);
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.dataMigration(auditCassandraDaoMock, artifactCassandraDaoMock);
- }
-
- @Test
- public void testArtifactCassandraDao() throws Exception {
- EsToCassandraDataMigrationConfig testSubject;
- ArtifactCassandraDao result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.artifactCassandraDao(mock(CassandraClient.class));
- }
-
- @Test
- public void testAuditCassandraDao() throws Exception {
- EsToCassandraDataMigrationConfig testSubject;
- AuditCassandraDao result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.auditCassandraDao(mock(CassandraClient.class));
- }
-
- @Test
- public void testCassandraClient() throws Exception {
- EsToCassandraDataMigrationConfig testSubject;
- CassandraClient result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.cassandraClient();
- }
-
- @Test
- public void testSdcSchemaFilesCassandraDao() throws Exception {
- EsToCassandraDataMigrationConfig testSubject;
- SdcSchemaFilesCassandraDao result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.sdcSchemaFilesCassandraDao(mock(CassandraClient.class));
- }
-}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/GraphJsonValidatorTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/GraphJsonValidatorTest.java
index 14b288b8f5..221d74cbe6 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/GraphJsonValidatorTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/GraphJsonValidatorTest.java
@@ -20,13 +20,13 @@
package org.openecomp.sdc.asdctool.impl;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
import org.junit.Test;
import java.nio.file.NoSuchFileException;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
public class GraphJsonValidatorTest {
private GraphJsonValidator createTestSubject() {
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/GraphMLConverterTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/GraphMLConverterTest.java
index a758526e48..87eb40d10b 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/GraphMLConverterTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/GraphMLConverterTest.java
@@ -20,9 +20,9 @@
package org.openecomp.sdc.asdctool.impl;
-import org.janusgraph.core.JanusGraph;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.tinkerpop.gremlin.structure.Element;
+import org.janusgraph.core.JanusGraph;
import org.junit.Test;
import java.util.List;
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ProductLogicTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ProductLogicTest.java
index 41381ed055..f0845fe8f4 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ProductLogicTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ProductLogicTest.java
@@ -20,9 +20,10 @@
package org.openecomp.sdc.asdctool.impl;
-import static org.junit.Assert.assertFalse;
import org.junit.Test;
+import static org.junit.Assert.assertFalse;
+
public class ProductLogicTest {
private ProductLogic createTestSubject() {
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/VrfObjectFixHandlerTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/VrfObjectFixHandlerTest.java
index 8dbb194c70..9e6b2e424e 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/VrfObjectFixHandlerTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/VrfObjectFixHandlerTest.java
@@ -26,9 +26,9 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
-import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.anyMap;
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/internal/tool/CsarGeneratorTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/internal/tool/CsarGeneratorTest.java
index 3be90e83b2..c297c23218 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/internal/tool/CsarGeneratorTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/internal/tool/CsarGeneratorTest.java
@@ -17,22 +17,7 @@
package org.openecomp.sdc.asdctool.impl.internal.tool;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.when;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.EnumMap;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Scanner;
-
+import fj.data.Either;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -55,8 +40,6 @@ import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
-
-import fj.data.Either;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.tosca.CsarUtils;
import org.openecomp.sdc.be.tosca.ToscaExportHandler;
@@ -66,6 +49,22 @@ import org.openecomp.sdc.common.api.ConfigurationSource;
import org.openecomp.sdc.common.impl.ExternalConfiguration;
import org.openecomp.sdc.common.impl.FSConfigurationSource;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Scanner;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
@RunWith(MockitoJUnitRunner.class)
public class CsarGeneratorTest {
@@ -319,6 +318,8 @@ public class CsarGeneratorTest {
.replace("\t\t\n", "\n")
.replace("\t\n", "\n")
.replace("\t\t", "\t")
+ .replace("\t\r", "")
+ .replace("\r", "")
.split("\n", -1);
}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/internal/tool/DeleteComponentHandlerTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/internal/tool/DeleteComponentHandlerTest.java
index b7e8eae560..b9cf317e70 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/internal/tool/DeleteComponentHandlerTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/internal/tool/DeleteComponentHandlerTest.java
@@ -29,8 +29,8 @@
*/
package org.openecomp.sdc.asdctool.impl.internal.tool;
-import org.janusgraph.core.JanusGraphVertex;
import fj.data.Either;
+import org.janusgraph.core.JanusGraphVertex;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentMatchers;
@@ -44,6 +44,7 @@ import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.TopologyTemplate;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.TopologyTemplateOperation;
+
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.HashMap;
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBLTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBLTest.java
index da3c858170..ee41d626b2 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBLTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBLTest.java
@@ -20,16 +20,16 @@
package org.openecomp.sdc.asdctool.impl.validator;
-import static org.mockito.Mockito.mock;
-
-import java.util.ArrayList;
import org.junit.Test;
import org.openecomp.sdc.asdctool.impl.validator.executers.NodeToscaArtifactsValidatorExecuter;
-
-import java.util.LinkedList;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
+import java.util.ArrayList;
+import java.util.LinkedList;
+
+import static org.mockito.Mockito.mock;
+
public class ArtifactToolBLTest {
private ArtifactToolBL createTestSubject() {
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBLTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBLTest.java
index 57c4d9c02e..f7f8307638 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBLTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBLTest.java
@@ -20,15 +20,14 @@
package org.openecomp.sdc.asdctool.impl.validator;
-import static org.mockito.Mockito.mock;
-
-import java.util.ArrayList;
import org.junit.Test;
import org.openecomp.sdc.asdctool.impl.validator.executers.ServiceValidatorExecuter;
+import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
+import java.util.ArrayList;
import java.util.LinkedList;
-import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
-import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
+
+import static org.mockito.Mockito.mock;
public class ValidationToolBLTest {
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java
index 201d307cea..31f6424e28 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java
@@ -20,13 +20,14 @@
package org.openecomp.sdc.asdctool.impl.validator.config;
-import static org.mockito.Mockito.mock;
-
-import java.util.ArrayList;
import org.junit.Test;
import org.openecomp.sdc.asdctool.impl.validator.ArtifactToolBL;
import org.openecomp.sdc.asdctool.impl.validator.ValidationToolBL;
-import org.openecomp.sdc.asdctool.impl.validator.executers.*;
+import org.openecomp.sdc.asdctool.impl.validator.executers.NodeToscaArtifactsValidatorExecuter;
+import org.openecomp.sdc.asdctool.impl.validator.executers.ServiceToscaArtifactsValidatorExecutor;
+import org.openecomp.sdc.asdctool.impl.validator.executers.ServiceValidatorExecuter;
+import org.openecomp.sdc.asdctool.impl.validator.executers.VFToscaArtifactValidatorExecutor;
+import org.openecomp.sdc.asdctool.impl.validator.executers.VfValidatorExecuter;
import org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts.ArtifactValidationUtils;
import org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts.ServiceArtifactValidationTask;
import org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts.VfArtifactValidationTask;
@@ -35,10 +36,15 @@ import org.openecomp.sdc.be.dao.JanusGraphClientStrategy;
import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao;
import org.openecomp.sdc.be.dao.cassandra.CassandraClient;
import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
-import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient;
+import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.model.DerivedNodeTypeResolver;
-import org.openecomp.sdc.be.model.jsonjanusgraph.operations.*;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.GroupsOperation;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.NodeTypeOperation;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.TopologyTemplateOperation;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
+
+import java.util.ArrayList;
import static org.mockito.Mockito.mock;
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecuterTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecuterTest.java
index a54463bc52..176a0ca79c 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecuterTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecuterTest.java
@@ -20,21 +20,21 @@
package org.openecomp.sdc.asdctool.impl.validator.executers;
-import static org.mockito.Mockito.mock;
-
import org.junit.Test;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
+import org.testng.Assert;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
-import org.testng.Assert;
+
+import static org.mockito.Mockito.mock;
public class ArtifactValidatorExecuterTest {
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecuterTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecuterTest.java
index a5f816c25c..e84b89af71 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecuterTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecuterTest.java
@@ -20,12 +20,12 @@
package org.openecomp.sdc.asdctool.impl.validator.executers;
-import static org.mockito.Mockito.mock;
-
import org.junit.Test;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
+import static org.mockito.Mockito.mock;
+
public class NodeToscaArtifactsValidatorExecuterTest {
private NodeToscaArtifactsValidatorExecuter createTestSubject() {
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutorTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutorTest.java
index 9c0571cbb8..51f1cc63da 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutorTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutorTest.java
@@ -20,12 +20,12 @@
package org.openecomp.sdc.asdctool.impl.validator.executers;
-import static org.mockito.Mockito.mock;
-
import org.junit.Test;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
+import static org.mockito.Mockito.mock;
+
public class ServiceToscaArtifactsValidatorExecutorTest {
private ServiceToscaArtifactsValidatorExecutor createTestSubject() {
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuterTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuterTest.java
index 6b243b359e..16e36369e6 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuterTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuterTest.java
@@ -20,11 +20,11 @@
package org.openecomp.sdc.asdctool.impl.validator.executers;
-import static org.mockito.Mockito.mock;
-
import org.junit.Test;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
+import static org.mockito.Mockito.mock;
+
public class ServiceValidatorExecuterTest {
private ServiceValidatorExecuter createTestSubject() {
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuterTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuterTest.java
index 41c04c37ec..6e3c15d58d 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuterTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuterTest.java
@@ -20,12 +20,12 @@
package org.openecomp.sdc.asdctool.impl.validator.executers;
-import static org.mockito.Mockito.mock;
-
import org.junit.Test;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import static org.mockito.Mockito.mock;
+
public class TopologyTemplateValidatorExecuterTest {
private TopologyTemplateValidatorExecuter createTestSubject() {
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutorTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutorTest.java
index 1dfd353087..bf9436336d 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutorTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutorTest.java
@@ -20,12 +20,12 @@
package org.openecomp.sdc.asdctool.impl.validator.executers;
-import static org.mockito.Mockito.mock;
-
import org.junit.Test;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
+import static org.mockito.Mockito.mock;
+
public class VFToscaArtifactValidatorExecutorTest {
private VFToscaArtifactValidatorExecutor createTestSubject() {
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuterTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuterTest.java
index 688f4ca108..457c9b0d19 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuterTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuterTest.java
@@ -20,14 +20,15 @@
package org.openecomp.sdc.asdctool.impl.validator.executers;
-import static org.mockito.Mockito.mock;
-
-import java.util.ArrayList;
-import java.util.List;
import org.junit.Test;
import org.openecomp.sdc.asdctool.impl.validator.tasks.VfValidationTask;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.mockito.Mockito.mock;
+
public class VfValidatorExecuterTest {
private VfValidatorExecuter createTestSubject() {
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtilsTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtilsTest.java
index 50e5f87305..b5ce1abca0 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtilsTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtilsTest.java
@@ -21,22 +21,7 @@
package org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.when;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.stream.IntStream;
-
+import fj.data.Either;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -44,26 +29,37 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-
import org.mockito.junit.MockitoJUnitRunner;
import org.openecomp.sdc.asdctool.impl.validator.config.ValidationConfigManager;
import org.openecomp.sdc.asdctool.impl.validator.utils.ReportManager;
import org.openecomp.sdc.asdctool.impl.validator.utils.ReportManagerHelper;
import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao;
import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
-
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition;
import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.TopologyTemplate;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.TopologyTemplateOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-
-import fj.data.Either;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.modules.junit4.PowerMockRunnerDelegate;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.IntStream;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
+
@RunWith(PowerMockRunner.class)
@PowerMockRunnerDelegate(MockitoJUnitRunner.class)
@PrepareForTest({ReportManager.class})
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTaskTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTaskTest.java
index d55f42131a..0aab99237b 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTaskTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTaskTest.java
@@ -20,11 +20,10 @@
package org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts;
-import static org.mockito.Mockito.mock;
-
import org.junit.Test;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
-import org.testng.Assert;
+
+import static org.mockito.Mockito.mock;
public class ServiceArtifactValidationTaskTest {
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTaskTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTaskTest.java
index a02f80a785..0dba9569ac 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTaskTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTaskTest.java
@@ -20,12 +20,12 @@
package org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts;
-import static org.mockito.Mockito.mock;
-
import org.junit.Test;
import org.openecomp.sdc.asdctool.impl.validator.utils.VertexResult;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import static org.mockito.Mockito.mock;
+
public class VfArtifactValidationTaskTest {
private VfArtifactValidationTask createTestSubject() {
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerHelper.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerHelper.java
index 9bcffbbf24..c832c47df4 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerHelper.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerHelper.java
@@ -20,6 +20,8 @@
package org.openecomp.sdc.asdctool.impl.validator.utils;
+import org.openecomp.sdc.asdctool.impl.validator.config.ValidationConfigManager;
+
import java.io.BufferedReader;
import java.io.IOException;
import java.nio.file.Files;
@@ -27,8 +29,6 @@ import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Collectors;
-import org.openecomp.sdc.asdctool.impl.validator.config.ValidationConfigManager;
-
public class ReportManagerHelper {
private ReportManagerHelper() {
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerTest.java
index c3cc3069bf..4926c1dee1 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerTest.java
@@ -21,17 +21,6 @@
package org.openecomp.sdc.asdctool.impl.validator.utils;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.when;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Objects;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -44,6 +33,17 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.modules.junit4.PowerMockRunnerDelegate;
+import java.io.File;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Objects;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.when;
+
@RunWith(PowerMockRunner.class)
@PowerMockRunnerDelegate(MockitoJUnitRunner.class)
@PrepareForTest({ReportManager.class})
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/main/ExportImportMenuTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/main/ExportImportMenuTest.java
deleted file mode 100644
index 497e116a57..0000000000
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/main/ExportImportMenuTest.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 Nokia Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.sdc.asdctool.main;
-
-import static org.junit.Assert.assertEquals;
-
-import java.nio.file.NoSuchFileException;
-import java.security.Permission;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.contrib.java.lang.system.ExpectedSystemExit;
-import org.junit.contrib.java.lang.system.SystemOutRule;
-
-public class ExportImportMenuTest{
-
- private static final String EXPORT_USAGE = "Usage: export <janusgraph.properties> <output directory>\n";
- private static final String EXPORT_AS_GRAPH_ML_USAGE = "Usage: export-as-graph-ml <janusgraph.properties> <output directory>\n";
- private static final String IMPORT_USAGE = "Usage: import <janusgraph.properties> <graph file location>\n";
- private static final String EXPORT_USERS_USAGE = "Usage: exportusers <janusgraph.properties> <output directory>\n";
- private static final String EXPORT_WITH_REPORT_USAGE = "Usage: export-as-graph-ml-with-data-report <janusgraph.properties> <output directory>\n";
- private static final String DATA_REPORT_USAGE = "Usage: get-data-report-from-graph-ml <full path of .graphml file>\n";
- private static final String VALIDATE_JSON_USAGE = "Usage: validate-json <export graph path>\n";
- private static final String FIND_PROBLEM_USAGE = "Usage: findproblem <janusgraph.properties> <graph file location>\n";
- private static final String USAGE = DATA_REPORT_USAGE + EXPORT_USAGE + EXPORT_AS_GRAPH_ML_USAGE + EXPORT_USERS_USAGE
- + EXPORT_WITH_REPORT_USAGE + FIND_PROBLEM_USAGE + IMPORT_USAGE + VALIDATE_JSON_USAGE;
- private static final String PARAM_3 = "param3";
- private static final String PARAM_2 = "param2";
- private static final String EXPORT = "export";
- private static final String EXPORT_AS_GRAPH_ML = "export-as-graph-ml";
- private static final String NONEXISTENT = "nonexistent";
- private static final String IMPORT = "import";
- private static final String EXPORT_USERS = "exportusers";
- private static final String DATA_REPORT = "get-data-report-from-graph-ml";
- private static final String FIND_PROBLEM = "findproblem";
- private static final String VALIDATE_JSON = "validate-json";
- private static final String EXPORT_WITH_REPORT = "export-as-graph-ml-with-data-report";
-
- @Rule
- public final SystemOutRule systemOutRule = new SystemOutRule().enableLog();
-
- @Rule
- public final ExpectedSystemExit exit = ExpectedSystemExit.none();
-
- @Test
- public void testOfMainWithInvalidLengthOfArgs() throws Exception {
- String [] args = {};
- exit.expectSystemExitWithStatus(1);
- ExportImportMenu.main(args);
- }
-
- @Test
- public void testOutputOfMainWithInvalidLengthOfArgs() {
- String [] args = {};
- callMainWithoutSystemExit(args);
- String log = systemOutRule.getLog();
- assertEquals(log, USAGE);
- }
-
- @Test
- public void testOfMainWithDefaultOperation() throws Exception {
- String [] args = {NONEXISTENT};
- exit.expectSystemExitWithStatus(1);
- ExportImportMenu.main(args);
- }
-
- @Test
- public void testOutputOfOfMainWithDefaultOperation() {
- String [] args = {NONEXISTENT};
- callMainWithoutSystemExit(args);
- String log = systemOutRule.getLog();
- assertEquals(log, USAGE);
- }
-
- @Test
- public void testOfMainWithExportOperationAndInvalidNoArgs() throws Exception {
- String [] args = {EXPORT};
- exit.expectSystemExitWithStatus(1);
- ExportImportMenu.main(args);
- }
-
- @Test
- public void testOutputOfMainWithExportOperationAndInvalidNoArgs(){
- String [] args = {EXPORT};
- callMainWithoutSystemExit(args);
- String log = systemOutRule.getLog();
- assertEquals(log, EXPORT_USAGE);
- }
-
- @Test
- public void testOfMainWithExportOperationAndValidNoArgs() throws Exception {
- String [] args = {EXPORT, PARAM_2, PARAM_3};
- exit.expectSystemExitWithStatus(2);
- ExportImportMenu.main(args);
- }
-
- @Test
- public void testOutputOfMainWithExportUsersOperationAndInvalidNoArgs(){
- String [] args = {EXPORT_USERS};
- callMainWithoutSystemExit(args);
- String log = systemOutRule.getLog();
- assertEquals(log, EXPORT_USERS_USAGE);
- }
-
- @Test
- public void testOfMainWithExportUsersOperationAndValidNoArgs() throws Exception {
- String [] args = {EXPORT_USERS, PARAM_2, PARAM_3};
- exit.expectSystemExitWithStatus(2);
- ExportImportMenu.main(args);
- }
-
- @Test
- public void testOutputOfMainWithImportOperationAndInvalidNoArgs(){
- String [] args = {IMPORT};
- callMainWithoutSystemExit(args);
- String log = systemOutRule.getLog();
- assertEquals(log, IMPORT_USAGE);
- }
-
- @Test
- public void testOfMainWithImportOperationAndValidNoArgs() throws Exception {
- String [] args = {IMPORT, PARAM_2, PARAM_3};
- exit.expectSystemExitWithStatus(2);
- ExportImportMenu.main(args);
- }
-
- @Test
- public void testOutputOfMainWithDataReportOperationAndInvalidNoArgs(){
- String [] args = {DATA_REPORT};
- callMainWithoutSystemExit(args);
- String log = systemOutRule.getLog();
- assertEquals(log, DATA_REPORT_USAGE);
- }
-
- @Test
- public void testOfMainWithDataReportOperationAndValidNoArgs() throws Exception {
- String [] args = {DATA_REPORT, PARAM_2};
- exit.expectSystemExitWithStatus(2);
- ExportImportMenu.main(args);
- }
-
- @Test
- public void testOutputOfMainWithExportAsGraphMLOperationAndInvalidNoArgs(){
- String [] args = {EXPORT_AS_GRAPH_ML};
- callMainWithoutSystemExit(args);
- String log = systemOutRule.getLog();
- assertEquals(log, EXPORT_AS_GRAPH_ML_USAGE);
- }
-
- @Test
- public void testMainWithExportAsGraphMLOperationAndInvalidNoArgs() throws Exception {
- String [] args = {EXPORT_AS_GRAPH_ML};
- exit.expectSystemExitWithStatus(1);
- ExportImportMenu.main(args);
- }
-
- @Test
- public void testOfMainWithExportAsGraphMLOperationAndValidNoArgs() throws Exception {
- String [] args = {EXPORT_AS_GRAPH_ML, PARAM_2, PARAM_3};
- exit.expectSystemExitWithStatus(2);
- ExportImportMenu.main(args);
- }
-
- @Test
- public void testOutputOfMainWithFindProblemOperationAndInvalidNoArgs(){
- String [] args = {FIND_PROBLEM};
- callMainWithoutSystemExit(args);
- String log = systemOutRule.getLog();
- assertEquals(log, FIND_PROBLEM_USAGE);
- }
-
- @Test
- public void testMainWithFindProblemOperationAndInvalidNoArgs() throws Exception {
- String [] args = {FIND_PROBLEM};
- exit.expectSystemExitWithStatus(1);
- ExportImportMenu.main(args);
- }
-
- @Test
- public void testOfMainWithFindProblemOperationAndValidNoArgs() throws Exception {
- String [] args = {FIND_PROBLEM, PARAM_2, PARAM_3};
- exit.expectSystemExitWithStatus(2);
- ExportImportMenu.main(args);
- }
-
- @Test
- public void testOutputOfMainWithExportWithReportOperationAndInvalidNoArgs(){
- String [] args = {EXPORT_WITH_REPORT};
- callMainWithoutSystemExit(args);
- String log = systemOutRule.getLog();
- assertEquals(log, EXPORT_WITH_REPORT_USAGE);
- }
-
- @Test
- public void testMainWithExportWithReportOperationAndInvalidNoArgs() throws Exception {
- String [] args = {EXPORT_WITH_REPORT};
- exit.expectSystemExitWithStatus(1);
- ExportImportMenu.main(args);
- }
-
- @Test
- public void testOfMainWithExportWithReportOperationAndValidNoArgs() throws Exception {
- String [] args = {EXPORT_WITH_REPORT, PARAM_2, PARAM_3};
- exit.expectSystemExitWithStatus(2);
- ExportImportMenu.main(args);
- }
-
- @Test
- public void testOutputOfMainWithValidateJsonOperationAndInvalidNoArgs(){
- String [] args = {VALIDATE_JSON};
- callMainWithoutSystemExit(args);
- String log = systemOutRule.getLog();
- assertEquals(log, VALIDATE_JSON_USAGE);
- }
-
- @Test
- public void testMainWithValidateJsonOperationAndInvalidNoArgs() throws Exception {
- String [] args = {VALIDATE_JSON};
- exit.expectSystemExitWithStatus(1);
- ExportImportMenu.main(args);
- }
-
- @Test(expected = NoSuchFileException.class)
- public void testOfMainWithValidateJsonOperationAndValidNoArgs() throws Exception {
- String [] args = {VALIDATE_JSON, PARAM_2, PARAM_3};
- ExportImportMenu.main(args);
- }
-
- private void callMainWithoutSystemExit(String[] params) {
-
- class NoExitException extends RuntimeException {}
-
- SecurityManager securityManager = System.getSecurityManager();
- System.setSecurityManager(new SecurityManager(){
-
- @Override
- public void checkPermission(Permission permission) {
- }
-
- @Override
- public void checkPermission(Permission permission, Object o) {
- }
-
- @Override
- public void checkExit(int status) {
- super.checkExit(status);
- throw new NoExitException();
- }
- });
- try {
- ExportImportMenu.main(params);
- }catch (Exception ignore){}
- System.setSecurityManager(securityManager);
- }
-
-} \ No newline at end of file
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/config/MigrationSpringConfigTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/config/MigrationSpringConfigTest.java
index ac5fa6eda3..3669fa970d 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/config/MigrationSpringConfigTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/config/MigrationSpringConfigTest.java
@@ -26,9 +26,7 @@ import org.openecomp.sdc.asdctool.migration.dao.MigrationTasksDao;
import org.openecomp.sdc.asdctool.migration.resolver.MigrationResolver;
import org.openecomp.sdc.asdctool.migration.resolver.SpringBeansMigrationResolver;
import org.openecomp.sdc.asdctool.migration.service.SdcRepoService;
-import org.openecomp.sdc.be.components.distribution.engine.ServiceDistributionArtifactsBuilder;
import org.openecomp.sdc.be.dao.cassandra.CassandraClient;
-import org.springframework.beans.factory.config.PropertiesFactoryBean;
import static org.mockito.Mockito.mock;
@@ -82,13 +80,5 @@ public class MigrationSpringConfigTest {
result = testSubject.migrationTasksDao(mock(CassandraClient.class));
}
- @Test
- public void testMapper() throws Exception {
- MigrationSpringConfig testSubject;
- PropertiesFactoryBean result;
- // default test
- testSubject = createTestSubject();
- result = testSubject.mapper();
- }
}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/core/SdcMigrationToolTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/core/SdcMigrationToolTest.java
index 2de6fc82f7..a9172a331b 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/core/SdcMigrationToolTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/core/SdcMigrationToolTest.java
@@ -35,7 +35,9 @@ import org.testng.annotations.Test;
import java.util.Arrays;
import java.util.Collections;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
public class SdcMigrationToolTest {
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/scanner/ClassScanner.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/scanner/ClassScanner.java
index 231d4dae95..81583033a6 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/scanner/ClassScanner.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/scanner/ClassScanner.java
@@ -26,7 +26,11 @@ import org.openecomp.sdc.asdctool.migration.core.MigrationException;
import java.io.File;
import java.lang.reflect.Modifier;
import java.net.URL;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
/**
* scan and instantiate classes of given type in the class path
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/service/SdcRepoServiceTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/service/SdcRepoServiceTest.java
index 5e6bab2a4e..ddcbb8bdc2 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/service/SdcRepoServiceTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/service/SdcRepoServiceTest.java
@@ -51,18 +51,11 @@ public class SdcRepoServiceTest {
@Test
public void testGetLatestVersion_noMinorVersionForCurrentVersion() {
- when(migrationTasksDaoMock.getLatestMinorVersion(DBVersion.CURRENT_VERSION.getMajor())).thenReturn(null);
+ when(migrationTasksDaoMock.getLatestMajorVersion()).thenReturn(DBVersion.DEFAULT_VERSION.getMajor());
+ when(migrationTasksDaoMock.getLatestMinorVersion(migrationTasksDaoMock.getLatestMajorVersion())).thenReturn(BigInteger.valueOf(0));
DBVersion latestDBVersion = testInstance.getLatestDBVersion();
- assertEquals(latestDBVersion.getMajor(), DBVersion.CURRENT_VERSION.getMajor());
- assertEquals(latestDBVersion.getMinor(), BigInteger.valueOf(Integer.MIN_VALUE));
- }
-
- @Test
- public void testGetLatestVersion() {
- when(migrationTasksDaoMock.getLatestMinorVersion(DBVersion.CURRENT_VERSION.getMajor())).thenReturn(BigInteger.TEN);
- DBVersion latestDBVersion = testInstance.getLatestDBVersion();
- assertEquals(latestDBVersion.getMajor(), DBVersion.CURRENT_VERSION.getMajor());
- assertEquals(latestDBVersion.getMinor(), BigInteger.TEN);
+ assertEquals(latestDBVersion.getMajor(), DBVersion.DEFAULT_VERSION.getMajor());
+ assertEquals(latestDBVersion.getMinor(), BigInteger.valueOf(0));
}
@Test
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/task/MigrationTasksTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/task/MigrationTasksTest.java
index e45e8989fd..138abf3c83 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/task/MigrationTasksTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/task/MigrationTasksTest.java
@@ -59,13 +59,13 @@ public class MigrationTasksTest {
@Test
public void testNoTaskWithVersionGreaterThanCurrentVersion() throws Exception {
- Set<Migration> migrationsWithVersionsGreaterThanCurrent = migrations.stream().filter(mig -> mig.getVersion().compareTo(DBVersion.CURRENT_VERSION) > 0)
+ Set<Migration> migrationsWithVersionsGreaterThanCurrent = migrations.stream().filter(mig -> mig.getVersion().compareTo(DBVersion.DEFAULT_VERSION) > 0)
.collect(Collectors.toSet());
if (!migrationsWithVersionsGreaterThanCurrent.isEmpty()) {
- Assert.fail(String.format("migrations tasks %s have version which is greater than DBVersion.CURRENT_VERSION %s. did you forget to update current version?",
+ Assert.fail(String.format("migrations tasks %s have version which is greater than DBVersion.DEFAULT_VERSION %s. did you forget to update current version?",
getMigrationsNameAsString(migrationsWithVersionsGreaterThanCurrent),
- DBVersion.CURRENT_VERSION.toString()));
+ DBVersion.DEFAULT_VERSION.toString()));
}
}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/handlers/XlsOutputHandlerTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/handlers/XlsOutputHandlerTest.java
index 8e1b482344..45212c3c6b 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/handlers/XlsOutputHandlerTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/handlers/XlsOutputHandlerTest.java
@@ -33,7 +33,9 @@ import java.io.IOException;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
@RunWith(MockitoJUnitRunner.class)
public class XlsOutputHandlerTest {
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1710/UpgradeMigration1710Test.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1710/UpgradeMigration1710Test.java
index 64e06ac5fb..8763a1bf68 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1710/UpgradeMigration1710Test.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1710/UpgradeMigration1710Test.java
@@ -51,11 +51,17 @@ import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
-import org.openecomp.sdc.be.model.*;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentParametersView;
+import org.openecomp.sdc.be.model.LifecycleStateEnum;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.Service;
+import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
-import org.openecomp.sdc.be.model.operations.api.IUserAdminOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.CsarOperation;
+import org.openecomp.sdc.be.model.operations.impl.UserAdminOperation;
import org.openecomp.sdc.common.api.ConfigurationSource;
import org.openecomp.sdc.common.http.client.api.HttpRequestHandler;
import org.openecomp.sdc.exception.ResponseFormat;
@@ -71,7 +77,10 @@ import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
public class UpgradeMigration1710Test {
@@ -89,7 +98,7 @@ public class UpgradeMigration1710Test {
@InjectMocks
private UpgradeMigration1710 migration = new UpgradeMigration1710();
@Mock
- private IUserAdminOperation userAdminOperation;
+ private UserAdminOperation userAdminOperation;
@Mock
private ToscaOperationFacade toscaOperationFacade;
@Mock
@@ -117,6 +126,7 @@ public class UpgradeMigration1710Test {
private static ConfigurationManager configurationManager;
private static List<String> resources = Stream.of("org.openecomp.resource.cp.extCP").collect(Collectors.toList());
private static Map<String, List<String>> resourcesForUpgrade;
+ private static Configuration.EnvironmentContext environmentContext = new Configuration.EnvironmentContext();
private Resource resource;
private Service service;
@@ -148,6 +158,8 @@ public class UpgradeMigration1710Test {
configurationManager.getConfiguration().setMaxDeleteComponents(5);
configurationManager.getConfiguration().setEnableAutoHealing(true);
configurationManager.getConfiguration().setToscaConformanceLevel("5.0");
+ environmentContext.setDefaultValue("General_Revenue-Bearing");
+ configurationManager.getConfiguration().setEnvironmentContext(environmentContext);
HashMap<String, List<String>> resourcesForUpgrade = new HashMap();
resourcesForUpgrade.put("5.0", Lists.newArrayList("port"));
configurationManager.getConfiguration().setResourcesForUpgrade(resourcesForUpgrade);
@@ -169,8 +181,6 @@ public class UpgradeMigration1710Test {
when(responseFormat.getFormattedMessage())
.thenReturn("");
- when(componentUtils.getResponseFormat(any(ActionStatus.class), any()))
- .thenReturn(responseFormat);
when(componentUtils.convertFromStorageResponse(any(), any())).thenCallRealMethod();
mockChangeComponentState();
}
@@ -525,7 +535,7 @@ public class UpgradeMigration1710Test {
when(janusGraphDao.getByCriteria(any(), any(), any(), any()))
.thenReturn(Either.left(components));
- when(janusGraphDao.getParentVertecies(any(GraphVertex.class), any(EdgeLabelEnum.class), any(JsonParseFlagEnum.class)))
+ when(janusGraphDao.getParentVertices(any(GraphVertex.class), any(EdgeLabelEnum.class), any(JsonParseFlagEnum.class)))
//1th node to upgrade
.thenReturn(Either.left(components))
//parent of the 1th node - stop recursion
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1802/SdcCatalogMigrationTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1802/SdcCatalogMigrationTest.java
index e07da1f102..2223d2847d 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1802/SdcCatalogMigrationTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1802/SdcCatalogMigrationTest.java
@@ -23,8 +23,8 @@ package org.openecomp.sdc.asdctool.migration.tasks.mig1802;
import org.junit.Test;
import org.openecomp.sdc.asdctool.migration.core.DBVersion;
import org.openecomp.sdc.asdctool.migration.core.task.MigrationResult;
-import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient;
+import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.TopologyTemplateOperation;
public class SdcCatalogMigrationTest {
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/ForwardPathMigrationTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/ForwardPathMigrationTest.java
index d657625479..071a30fea2 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/ForwardPathMigrationTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/ForwardPathMigrationTest.java
@@ -20,8 +20,6 @@
package org.openecomp.sdc.asdctool.migration.tasks.mig1806;
-import static org.junit.Assert.assertThat;
-import java.math.BigInteger;
import org.hamcrest.core.Is;
import org.hamcrest.core.IsNull;
import org.junit.Before;
@@ -32,6 +30,10 @@ import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.operations.impl.UserAdminOperation;
+import java.math.BigInteger;
+
+import static org.junit.Assert.assertThat;
+
public class ForwardPathMigrationTest {
ForwardPathMigration forwardPathMigration = null;
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/ResourceLifecycleMigrationTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/ResourceLifecycleMigrationTest.java
index 820ea05392..d11f70c4bb 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/ResourceLifecycleMigrationTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/ResourceLifecycleMigrationTest.java
@@ -20,8 +20,6 @@
package org.openecomp.sdc.asdctool.migration.tasks.mig1806;
-import static org.junit.Assert.assertThat;
-import java.math.BigInteger;
import org.hamcrest.core.Is;
import org.hamcrest.core.IsNull;
import org.junit.Before;
@@ -34,6 +32,10 @@ import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.model.operations.impl.UserAdminOperation;
+import java.math.BigInteger;
+
+import static org.junit.Assert.assertThat;
+
@RunWith(MockitoJUnitRunner.class)
public class ResourceLifecycleMigrationTest {
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/SDCInstancesMigrationTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/SDCInstancesMigrationTest.java
index e40c4146f6..4721b1eb02 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/SDCInstancesMigrationTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/SDCInstancesMigrationTest.java
@@ -52,6 +52,8 @@ public class SDCInstancesMigrationTest{
private JanusGraphDao janusGraphDao;
@Mock
private NodeTemplateOperation nodeTemplateOperation;
+ @Mock
+ GraphVertex topologyTemplateVertex;
@Test
@@ -79,10 +81,13 @@ public class SDCInstancesMigrationTest{
vertexOrig.setJson(jsonComposition);
vertexOrig.setType(ComponentTypeEnum.SERVICE);
list.add(vertexOrig);
-
+
+
+ when(janusGraphDao.getVertexById(any())).thenReturn(Either.left(vertexOrig));
when(janusGraphDao.getByCriteria(any(), any(), any(), any() )).thenReturn(Either.left(list));
when(nodeTemplateOperation.createInstanceEdge(vertexOrig, instance)).thenReturn(StorageOperationStatus.OK);
-
+ when(janusGraphDao.commit()).thenReturn(JanusGraphOperationStatus.OK);
+
MigrationResult migrate = instancesMigration.migrate();
MigrationStatus migrationStatus = migrate.getMigrationStatus();
assertEquals(MigrationStatus.COMPLETED, migrationStatus);
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/SdcArchiveMigrationTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/SdcArchiveMigrationTest.java
index 51bbf705ad..03695367b0 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/SdcArchiveMigrationTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1806/SdcArchiveMigrationTest.java
@@ -20,8 +20,6 @@
package org.openecomp.sdc.asdctool.migration.tasks.mig1806;
-import static org.junit.Assert.assertThat;
-import java.math.BigInteger;
import org.hamcrest.core.Is;
import org.hamcrest.core.IsNull;
import org.junit.Before;
@@ -32,6 +30,10 @@ import org.mockito.junit.MockitoJUnitRunner;
import org.openecomp.sdc.asdctool.migration.core.DBVersion;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
+import java.math.BigInteger;
+
+import static org.junit.Assert.assertThat;
+
@RunWith(MockitoJUnitRunner.class)
public class SdcArchiveMigrationTest {
@Mock
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1902/SdcGroupsMigrationTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1902/SdcGroupsMigrationTest.java
new file mode 100644
index 0000000000..328c5f3459
--- /dev/null
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1902/SdcGroupsMigrationTest.java
@@ -0,0 +1,231 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.asdctool.migration.tasks.mig1902;
+
+import fj.data.Either;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.openecomp.sdc.asdctool.migration.core.task.MigrationResult;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
+import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
+import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
+import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
+import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
+import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
+import org.openecomp.sdc.be.model.GroupTypeDefinition;
+import org.openecomp.sdc.be.model.PropertyDefinition;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.be.model.operations.impl.GroupTypeOperation;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyMap;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
+public class SdcGroupsMigrationTest {
+
+ @Mock
+ private JanusGraphDao janusGraphDao;
+ @Mock
+ private GroupTypeOperation groupTypeOperation;
+ @Mock
+ private GraphVertex topologyTemplateVertex;
+ @Mock
+ private GraphVertex groupsVertex;
+
+ @InjectMocks
+ private SdcGroupsMigration groupsMigration;
+
+ @Before
+ public void setUp() {
+ groupsMigration = new SdcGroupsMigration(janusGraphDao, groupTypeOperation);
+ when(janusGraphDao.getVertexById(any())).thenReturn(Either.left(topologyTemplateVertex));
+ }
+
+ @Test
+ public void handleOneContainerWhenErrorHappened() {
+ when(janusGraphDao.getChildVertex(any(GraphVertex.class), eq(EdgeLabelEnum.GROUPS), eq(JsonParseFlagEnum.ParseAll)))
+ .thenReturn(Either.right(JanusGraphOperationStatus.MATCH_NOT_FOUND));
+ StorageOperationStatus status = groupsMigration.handleOneContainer(topologyTemplateVertex);
+ assertEquals(StorageOperationStatus.MATCH_NOT_FOUND, status);
+ }
+
+ @Test
+ public void handleOneContainerWhenNoGroups() {
+ when(janusGraphDao.getChildVertex(any(GraphVertex.class), eq(EdgeLabelEnum.GROUPS), eq(JsonParseFlagEnum.ParseAll)))
+ .thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
+ StorageOperationStatus status = groupsMigration.handleOneContainer(topologyTemplateVertex);
+ assertEquals(StorageOperationStatus.OK, status);
+ }
+
+ @Test
+ public void handleOneContainerWhenGroupsShouldNotBeUpdated() {
+ when(janusGraphDao.getChildVertex(any(GraphVertex.class), eq(EdgeLabelEnum.GROUPS), eq(JsonParseFlagEnum.ParseAll)))
+ .thenReturn(Either.left(groupsVertex));
+
+ doReturn(buildGroupInstancesMap(new String[] {"org.openecomp.groups.heat.HeatStack", "org.openecomp.groups.VfModule"}, new String[]{}))
+ .when(groupsVertex).getJson();
+ StorageOperationStatus status = groupsMigration.handleOneContainer(topologyTemplateVertex);
+ assertEquals(StorageOperationStatus.OK, status);
+ verify(janusGraphDao, times(0)).commit();
+
+ }
+
+ @Test
+ public void handleOneContainerWhenGroupsShouldBeUpdated() {
+ mockLatestGroupMapCreating();
+ mockUpgradeHappyFlow();
+ StorageOperationStatus status = groupsMigration.handleOneContainer(topologyTemplateVertex);
+ assertEquals(StorageOperationStatus.OK, status);
+ verify(janusGraphDao, times(1)).commit();
+ verify(janusGraphDao, times(0)).rollback();
+ }
+
+ private void mockUpgradeHappyFlow() {
+ when(janusGraphDao.getChildVertex(any(GraphVertex.class), eq(EdgeLabelEnum.GROUPS), eq(JsonParseFlagEnum.ParseAll)))
+ .thenReturn(Either.left(groupsVertex));
+ when(janusGraphDao.updateVertex(any(GraphVertex.class))).thenReturn(Either.left(groupsVertex));
+ when(janusGraphDao.commit()).thenReturn(JanusGraphOperationStatus.OK);
+ doReturn(buildGroupInstancesMap(new String[] {"org.openecomp.groups.NetworkCollection", "org.openecomp.groups.VfcInstanceGroup"},
+ new String[] {"old1", "old2"}))
+ .when(groupsVertex).getJson();
+ }
+
+ @Test
+ public void handleOneContainerWhenGroupsAlreadyUpdated() {
+ mockLatestGroupMapCreating();
+ when(janusGraphDao.getChildVertex(any(GraphVertex.class), eq(EdgeLabelEnum.GROUPS), eq(JsonParseFlagEnum.ParseAll)))
+ .thenReturn(Either.left(groupsVertex));
+ doReturn(buildGroupInstancesMap(new String[] {"org.openecomp.groups.NetworkCollection"},
+ new String[] {"a", "b", "c", "d"}))
+ .when(groupsVertex).getJson();
+ StorageOperationStatus status = groupsMigration.handleOneContainer(topologyTemplateVertex);
+ assertEquals(StorageOperationStatus.OK, status);
+ verify(janusGraphDao, times(0)).commit();
+ verify(janusGraphDao, times(1)).rollback();
+ }
+
+ @Test
+ public void handleOneContainerWhenExceptionIsThrown() {
+ when(janusGraphDao.getChildVertex(any(GraphVertex.class), eq(EdgeLabelEnum.GROUPS), eq(JsonParseFlagEnum.ParseAll)))
+ .thenThrow(new RuntimeException());
+ StorageOperationStatus status = groupsMigration.handleOneContainer(topologyTemplateVertex);
+ assertEquals(StorageOperationStatus.GENERAL_ERROR, status);
+ verify(janusGraphDao, times(0)).commit();
+ verify(janusGraphDao, times(1)).rollback();
+
+ }
+
+ // A temp remark for this test - following Commit hash: 08595ad21b0c409c69e3902232f5575963199e3e [ASDC-641] – Migration workaround for deployment artifact timeout. Reviewer: Lior.
+// @Test
+// public void migrateWhenExceptionIsThrown() {
+// List<GraphVertex> vertexList = new ArrayList<>();
+// vertexList.add(topologyTemplateVertex);
+// mockLatestGroupMapCreating();
+// when(janusGraphDao.getByCriteria(eq(VertexTypeEnum.TOPOLOGY_TEMPLATE), eq(null), anyMap(), eq(JsonParseFlagEnum.ParseAll)))
+// .thenReturn(Either.left(vertexList));
+// when(janusGraphDao.getChildVertex(any(GraphVertex.class), eq(EdgeLabelEnum.GROUPS), eq(JsonParseFlagEnum.ParseAll)))
+// .thenThrow(new RuntimeException());
+// assertEquals(MigrationResult.MigrationStatus.FAILED, groupsMigration.migrate().getMigrationStatus());
+// verify(janusGraphDao, times(0)).commit();
+// verify(janusGraphDao, times(1)).rollback();
+//
+// }
+
+ @Test
+ public void migrateWhenGroupsShouldBeUpdated() {
+ List<GraphVertex> vertexList = new ArrayList<>();
+ vertexList.add(topologyTemplateVertex);
+ mockLatestGroupMapCreating();
+ when(janusGraphDao.getByCriteria(eq(VertexTypeEnum.TOPOLOGY_TEMPLATE), eq(null), anyMap(), eq(JsonParseFlagEnum.ParseAll)))
+ .thenReturn(Either.left(vertexList));
+ mockUpgradeHappyFlow();
+
+ assertEquals(MigrationResult.MigrationStatus.COMPLETED, groupsMigration.migrate().getMigrationStatus());
+ verify(janusGraphDao, times(1)).commit();
+ verify(janusGraphDao, times(0)).rollback();
+ }
+
+
+ private Map<String, GroupDataDefinition> buildGroupInstancesMap(String[] groupTypes, String [] propertyNames) {
+ Map<String, GroupDataDefinition> groupsMap = new HashMap<>();
+ for (String type: groupTypes) {
+ GroupDataDefinition gr = new GroupDataDefinition();
+ gr.setType(type);
+
+ gr.setProperties(createInstanceProperties(propertyNames));
+ groupsMap.put(gr.getType(), gr);
+ }
+ return groupsMap;
+ }
+
+ private void mockLatestGroupMapCreating() {
+ doReturn(Either.left(createTypeDefinition(new String[] {"a", "b", "c", "d"})))
+ .when(groupTypeOperation).getLatestGroupTypeByType(eq(SdcGroupsMigration.GroupsForUpgrade.NW_COLLECTION_GROUP_NAME.getToscaType()), eq(false));
+ doReturn(Either.left(createTypeDefinition(new String[] {"l", "m", "n", "o", "p"})))
+ .when(groupTypeOperation).getLatestGroupTypeByType(eq(SdcGroupsMigration.GroupsForUpgrade.VFC_INSTANCE_GROUP_NAME.getToscaType()), eq(false));
+ groupsMigration.loadLatestGroupTypeDefinitions();
+
+ }
+
+ private GroupTypeDefinition createTypeDefinition(String[] propertyNames) {
+ GroupTypeDefinition typeDefinition = new GroupTypeDefinition();
+ typeDefinition.setProperties(createTypeProperties(propertyNames));
+ return typeDefinition;
+ }
+
+ private List<PropertyDefinition> createTypeProperties(String[] propertyNames) {
+ List<PropertyDefinition> propertyDefinitionList = new ArrayList<>();
+ for (String name: propertyNames) {
+ PropertyDefinition propertyDefinition = new PropertyDefinition();
+ propertyDefinition.setName(name);
+ propertyDefinitionList.add(propertyDefinition);
+ }
+ return propertyDefinitionList;
+ }
+
+ private List<PropertyDataDefinition> createInstanceProperties(String[] propertyNames) {
+ List<PropertyDataDefinition> propertyDefinitionList = new ArrayList<>();
+ for (String name: propertyNames) {
+ PropertyDefinition propertyDefinition = new PropertyDefinition();
+ propertyDefinition.setName(name);
+ propertyDefinitionList.add(propertyDefinition);
+ }
+ return propertyDefinitionList;
+ }
+
+}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1902/SdcResourceIconMigrationTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1902/SdcResourceIconMigrationTest.java
new file mode 100644
index 0000000000..172b8a63f2
--- /dev/null
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/migration/tasks/mig1902/SdcResourceIconMigrationTest.java
@@ -0,0 +1,213 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.asdctool.migration.tasks.mig1902;
+
+import fj.data.Either;
+import org.assertj.core.util.Lists;
+import org.assertj.core.util.Maps;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.openecomp.sdc.asdctool.migration.core.task.MigrationResult;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
+import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
+import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
+import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
+import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.CompositionDataDefinition;
+import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
+import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
+import org.openecomp.sdc.be.model.jsonjanusgraph.enums.JsonConstantKeysEnum;
+
+import java.util.HashMap;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.anyMap;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
+public class SdcResourceIconMigrationTest {
+ @Mock
+ private JanusGraphDao janusGraphDao;
+
+ @Mock
+ private GraphVertex graphVertex;
+
+ @Mock
+ private GraphVertex topologyTemplateVertex;
+
+ @Mock
+ private CompositionDataDefinition compositionDataDefinition;
+
+ @Mock
+ private ComponentInstanceDataDefinition componentInstanceDataDefinition;
+
+ @InjectMocks
+ private SdcResourceIconMigration iconMigration;
+
+ @Before
+ public void setUp() {
+ iconMigration = new SdcResourceIconMigration(janusGraphDao);
+ when(janusGraphDao.getVertexById(any())).thenReturn(Either.left(topologyTemplateVertex));
+ when(janusGraphDao.commit()).thenReturn(JanusGraphOperationStatus.OK);
+ }
+
+
+ @Test
+ public void migrationFailedWhenNoNodeTypeDefined() {
+ when(janusGraphDao.getByCriteria(eq(VertexTypeEnum.NODE_TYPE), anyMap(), anyMap(), eq(JsonParseFlagEnum.ParseAll)))
+ .thenReturn(Either.left(Lists.emptyList()));
+ assertEquals(MigrationResult.MigrationStatus.FAILED, iconMigration.migrate().getMigrationStatus());
+ }
+
+ @Test
+ public void resourceIsNotUpdatedIfNotVL() {
+ //iconMigration.handleOneContainer(graphVertex);
+ mockInstancesNotFoundFlow();
+
+ iconMigration.updateNodeTypeIconAndStoreInMap(ResourceTypeEnum.VL);
+ assertFalse(iconMigration.updateIconInsideInstance(componentInstanceDataDefinition));
+ }
+
+
+
+ @Test
+ public void resourceIsUpdatedIfCP() {
+ //iconMigration.handleOneContainer(graphVertex);
+ mockInstancesFoundFlow();
+ when(janusGraphDao.updateVertex(any(GraphVertex.class))).thenReturn(Either.left(graphVertex));
+ iconMigration.updateNodeTypeIconAndStoreInMap(ResourceTypeEnum.CP);
+ assertTrue(iconMigration.updateIconInsideInstance(componentInstanceDataDefinition));
+ }
+
+ @Test
+ public void migrateWhenIconsAreUpdated() {
+ mockInstancesFoundFlow();
+ when(janusGraphDao.getByCriteria(eq(VertexTypeEnum.TOPOLOGY_TEMPLATE), eq(null), anyMap(), eq(JsonParseFlagEnum.ParseAll)))
+ .thenReturn(Either.left(Lists.newArrayList(topologyTemplateVertex)));
+ when(compositionDataDefinition.getComponentInstances()).thenReturn(Maps.newHashMap("a", componentInstanceDataDefinition));
+ doReturn(Maps.newHashMap(JsonConstantKeysEnum.COMPOSITION.getValue(), compositionDataDefinition)).when(topologyTemplateVertex).getJson();
+ when(janusGraphDao.updateVertex(any(GraphVertex.class))).thenReturn(Either.left(graphVertex));
+
+ assertEquals(MigrationResult.MigrationStatus.COMPLETED, iconMigration.migrate().getMigrationStatus());
+ verify(janusGraphDao, times(3)).commit();
+ }
+
+ @Test
+ public void migrateWhenIconsNotUpdated() {
+ mockInstancesNotFoundFlow();
+ when(janusGraphDao.getByCriteria(eq(VertexTypeEnum.TOPOLOGY_TEMPLATE), eq(null), anyMap(), eq(JsonParseFlagEnum.ParseAll)))
+ .thenReturn(Either.left(Lists.newArrayList(topologyTemplateVertex)));
+ when(compositionDataDefinition.getComponentInstances()).thenReturn(Maps.newHashMap("a", componentInstanceDataDefinition));
+ doReturn(Maps.newHashMap(JsonConstantKeysEnum.COMPOSITION.getValue(), compositionDataDefinition)).when(topologyTemplateVertex).getJson();
+
+ assertEquals(MigrationResult.MigrationStatus.COMPLETED, iconMigration.migrate().getMigrationStatus());
+ verify(janusGraphDao, times(2)).commit();
+ }
+
+ @Test
+ public void migrateWhenNoInstancesFound() {
+ mockInstancesNotFoundFlow();
+ when(janusGraphDao.getByCriteria(eq(VertexTypeEnum.TOPOLOGY_TEMPLATE), eq(null), anyMap(), eq(JsonParseFlagEnum.ParseAll)))
+ .thenReturn(Either.left(Lists.newArrayList(topologyTemplateVertex)));
+
+ assertEquals(MigrationResult.MigrationStatus.COMPLETED, iconMigration.migrate().getMigrationStatus());
+ verify(janusGraphDao, times(2)).commit();
+ }
+
+ // A temp remark for this test - following Commit hash: 08595ad21b0c409c69e3902232f5575963199e3e [ASDC-641] – Migration workaround for deployment artifact timeout. Reviewer: Lior.
+// @Test
+// public void migrationFailedWhenInstanceVertexUpdateFailed() {
+// mockInstancesFoundFlow();
+// when(janusGraphDao.getByCriteria(eq(VertexTypeEnum.TOPOLOGY_TEMPLATE), eq(null), anyMap(), eq(JsonParseFlagEnum.ParseAll)))
+// .thenReturn(Either.left(Lists.newArrayList(topologyTemplateVertex)));
+// when(compositionDataDefinition.getComponentInstances()).thenReturn(Maps.newHashMap("a", componentInstanceDataDefinition));
+// doReturn(Maps.newHashMap(JsonConstantKeysEnum.COMPOSITION.getValue(), compositionDataDefinition)).when(topologyTemplateVertex).getJson();
+// when(janusGraphDao.updateVertex(any(GraphVertex.class))).thenReturn(Either.left(graphVertex))
+// .thenReturn(Either.left(graphVertex))
+// .thenReturn(Either.right(JanusGraphOperationStatus.GENERAL_ERROR));
+//
+// assertEquals(MigrationResult.MigrationStatus.FAILED, iconMigration.migrate().getMigrationStatus());
+// verify(janusGraphDao, times(2)).commit();
+// }
+
+ @Test
+ public void migrationCompletedWhenVertexJsonIsEmpty() {
+ mockInstancesFoundFlow();
+ when(janusGraphDao.getByCriteria(eq(VertexTypeEnum.TOPOLOGY_TEMPLATE), eq(null), anyMap(), eq(JsonParseFlagEnum.ParseAll)))
+ .thenReturn(Either.left(Lists.newArrayList(topologyTemplateVertex)));
+ doReturn(new HashMap<>()).when(topologyTemplateVertex).getJson();
+ when(janusGraphDao.updateVertex(any(GraphVertex.class))).thenReturn(Either.left(graphVertex));
+
+ assertEquals(MigrationResult.MigrationStatus.COMPLETED, iconMigration.migrate().getMigrationStatus());
+ verify(janusGraphDao, times(2)).commit();
+ }
+
+ @Test
+ public void migrationCompletedWhenVertexJsonIsNull() {
+ mockInstancesFoundFlow();
+ when(janusGraphDao.getByCriteria(eq(VertexTypeEnum.TOPOLOGY_TEMPLATE), eq(null), anyMap(), eq(JsonParseFlagEnum.ParseAll)))
+ .thenReturn(Either.left(Lists.newArrayList(topologyTemplateVertex)));
+ doReturn(null).when(topologyTemplateVertex).getJson();
+ when(janusGraphDao.updateVertex(any(GraphVertex.class))).thenReturn(Either.left(graphVertex));
+
+ assertEquals(MigrationResult.MigrationStatus.COMPLETED, iconMigration.migrate().getMigrationStatus());
+ verify(janusGraphDao, times(2)).commit();
+ }
+
+ @Test
+ public void migrationFailedWhenTypeUpdateFailed() {
+ mockInstancesFoundFlow();
+ when(janusGraphDao.updateVertex(any(GraphVertex.class))).thenReturn(Either.right(JanusGraphOperationStatus.GENERAL_ERROR));
+ assertEquals(MigrationResult.MigrationStatus.FAILED, iconMigration.migrate().getMigrationStatus());
+ verify(janusGraphDao, times(0)).commit();
+ }
+
+ private void mockInstancesNotFoundFlow() {
+ List<GraphVertex> nodeTypeVertexList = Lists.newArrayList(graphVertex);
+ when(graphVertex.getMetadataProperty(GraphPropertyEnum.NAME)).thenReturn("vl1");
+ when(componentInstanceDataDefinition.getComponentName()).thenReturn("other");
+ when(janusGraphDao.getByCriteria(eq(VertexTypeEnum.NODE_TYPE), anyMap(), anyMap(), eq(JsonParseFlagEnum.ParseAll)))
+ .thenReturn(Either.left(nodeTypeVertexList));
+ when(janusGraphDao.updateVertex(any(GraphVertex.class))).thenReturn(Either.left(graphVertex));
+ }
+
+ private void mockInstancesFoundFlow() {
+ when(graphVertex.getMetadataProperty(GraphPropertyEnum.NAME)).thenReturn(String.valueOf("cp1"));
+ when(componentInstanceDataDefinition.getComponentName()).thenReturn("cp1");
+ when(janusGraphDao.getByCriteria(eq(VertexTypeEnum.NODE_TYPE), anyMap(), anyMap(), eq(JsonParseFlagEnum.ParseAll)))
+ .thenReturn(Either.left(Lists.newArrayList(graphVertex)));
+ }
+
+
+}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/utils/ReportWriterTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/utils/ReportWriterTest.java
index 95e50b723e..f8e2c5ca5d 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/utils/ReportWriterTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/utils/ReportWriterTest.java
@@ -34,6 +34,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+
import java.io.IOException;
@RunWith(MockitoJUnitRunner.class)