summaryrefslogtreecommitdiffstats
path: root/src/test/java/org
diff options
context:
space:
mode:
authorArul.Nambi <arul.nambi@amdocs.com>2017-10-10 17:05:00 -0400
committerArul.Nambi <arul.nambi@amdocs.com>2017-10-10 17:05:27 -0400
commit57ebc748b30fc61ea3bee40abf0fd8b41b785088 (patch)
tree5a73552897418397ad8466f887991770a571aac7 /src/test/java/org
parent645628777792e49ea18f245236953a9e5aa6c6f7 (diff)
Increase junit coverage
Issue-ID: AAI-429 Change-Id: I8e9c8a7a04fa2433e888a48dd09c5424e9986e07 Signed-off-by: Arul.Nambi <arul.nambi@amdocs.com>
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/onap/aai/sparky/inventory/GeoIndexDocumentTest.java121
-rw-r--r--src/test/java/org/onap/aai/sparky/synchronizer/SyncControllerBuilder.java45
-rw-r--r--src/test/java/org/onap/aai/sparky/synchronizer/SyncHelperTest.java20
-rw-r--r--src/test/java/org/onap/aai/sparky/util/ElasticEntitySummarizer.java63
-rw-r--r--src/test/java/org/onap/aai/sparky/util/LogValidator.java7
-rw-r--r--src/test/java/org/onap/aai/sparky/util/ModelLoaderTester.java46
-rw-r--r--src/test/java/org/onap/aai/sparky/util/UtilPojoTest.java43
-rw-r--r--src/test/java/org/onap/aai/sparky/viewandinspect/ActiveInventoryNodeTester.java24
-rw-r--r--src/test/java/org/onap/aai/sparky/viewandinspect/SelfLinkNodeCollectorTester.java69
9 files changed, 104 insertions, 334 deletions
diff --git a/src/test/java/org/onap/aai/sparky/inventory/GeoIndexDocumentTest.java b/src/test/java/org/onap/aai/sparky/inventory/GeoIndexDocumentTest.java
deleted file mode 100644
index d2cddcb..0000000
--- a/src/test/java/org/onap/aai/sparky/inventory/GeoIndexDocumentTest.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
-* ============LICENSE_START=======================================================
-* SPARKY (AAI UI service)
-* ================================================================================
-* Copyright © 2017 AT&T Intellectual Property.
-* Copyright © 2017 Amdocs
-* 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=========================================================
-*
-* ECOMP and OpenECOMP are trademarks
-* and service marks of AT&T Intellectual Property.
-*/
-
-package org.onap.aai.sparky.inventory;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.aai.sparky.inventory.entity.GeoIndexDocument;
-
-/**
- * The Class GeoIndexDocumentTest.
- */
-@RunWith(MockitoJUnitRunner.class)
-public class GeoIndexDocumentTest {
-
- /**
- * Inits the.
- *
- * @throws Exception the exception
- */
- @Before
- public void init() throws Exception {}
-
- /**
- * Checks if is valid geo index document success path.
- */
- @Test
- public void isValidGeoIndexDocument_successPath() {
-
- GeoIndexDocument geoDoc = new GeoIndexDocument();
-
- geoDoc.setEntityPrimaryKeyName("pkeyName");
- geoDoc.setEntityPrimaryKeyValue("pkeyValue");
- geoDoc.setEntityType("type");
- geoDoc.setId("12312");
- geoDoc.setLatitude("-45.123");
- geoDoc.setLongitude("181.321");
- geoDoc.setSelfLink("https://server.somewhere.com:8443/aai/v7/id");
-
- assertTrue(geoDoc.isValidGeoDocument());
-
- }
-
- /**
- * Checks if is valid geo index document fail no geo coordinates.
- */
- @Test
- public void isValidGeoIndexDocument_fail_no_geoCoordinates() {
-
- GeoIndexDocument geoIndexDoc = new GeoIndexDocument();
-
- geoIndexDoc.setEntityPrimaryKeyName("pkeyName");
- geoIndexDoc.setEntityPrimaryKeyValue("pkeyValue");
- geoIndexDoc.setEntityType("type");
- geoIndexDoc.setId("12312");
- geoIndexDoc.setSelfLink("https://server.somewhere.com:8443/aai/v7/id");
-
- assertFalse(geoIndexDoc.isValidGeoDocument());
-
- }
-
- /**
- * Checks if is valid geo index document fail invalid geo coordinates.
- */
- @Test
- public void isValidGeoIndexDocument_fail_invalid_geoCoordinates() {
-
- GeoIndexDocument geoIndexDoc = new GeoIndexDocument();
-
- geoIndexDoc.setEntityPrimaryKeyName("pkeyName");
- geoIndexDoc.setEntityPrimaryKeyValue("pkeyValue");
- geoIndexDoc.setEntityType("type");
- geoIndexDoc.setId("12312");
- geoIndexDoc.setLatitude("not_a_valid");
- geoIndexDoc.setLongitude("geo point");
-
- geoIndexDoc.setSelfLink("https://server.somewhere.com:8443/aai/v7/id");
-
- assertFalse(geoIndexDoc.isValidGeoDocument());
-
- }
-
- /**
- * Checks if is valid geo index document fail nothing set.
- */
- @Test
- public void isValidGeoIndexDocument_fail_nothing_set() {
-
- GeoIndexDocument geoIndexDoc = new GeoIndexDocument();
-
- assertFalse(geoIndexDoc.isValidGeoDocument());
-
- }
-}
diff --git a/src/test/java/org/onap/aai/sparky/synchronizer/SyncControllerBuilder.java b/src/test/java/org/onap/aai/sparky/synchronizer/SyncControllerBuilder.java
index bcd0c9a..e97da4f 100644
--- a/src/test/java/org/onap/aai/sparky/synchronizer/SyncControllerBuilder.java
+++ b/src/test/java/org/onap/aai/sparky/synchronizer/SyncControllerBuilder.java
@@ -522,49 +522,4 @@ public class SyncControllerBuilder {
}
}
-
- /**
- * The main method.
- *
- * @param args the arguments
- */
- public static void main(String[] args) {
- boolean runSearchableEntitySync = false;
- boolean runGeoEntitySync = true;
-
- System.setProperty("AJSC_HOME", "e:\\dev");
- // System.getProperties().setProperty("AJSC_HOME",
- // "c:\\rpo\\tier-support-ui\\target\\swm\\package\\nix\\"
- // + "dist_files\\opt\\app\\ajsc-tier-support-ui");
- System.setProperty("AJSC_HOME", "d:\\AAI\\tier_support_ui\\tier-support-ui\\target\\swm\\package\\nix\\dist_files\\appl\\inventory-ui-service\\1.0-SNAPSHOT");
-
- ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory
- .getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
- // root.detachAndStopAllAppenders();
- // logger = new CaptureLoggerAppender();
- root.setLevel(Level.INFO);
- // root.addAppender(logger);
-
-
- SyncControllerBuilder syncBuilder = new SyncControllerBuilder();
-
- /*
- * if (runSearchableEntitySync) syncBuilder.doSearchableEntitysync();
- */
-
- //syncBuilder.doSearchableEntitysync();
- // syncBuilder.doCrossEntityReferenceSync();
- // syncBuilder.doHistoricalEntitySync();
- // syncBuilder.doGeoEntitySync();
- syncBuilder.doSuggestionEntitySync();
-
- // syncBuilder.testElasticSearchUpdateAPI();
-
- /*
- * if (runGeoEntitySync) { syncBuilder.doGeoEntitySync(); }
- */
-
-
-
- }
}
diff --git a/src/test/java/org/onap/aai/sparky/synchronizer/SyncHelperTest.java b/src/test/java/org/onap/aai/sparky/synchronizer/SyncHelperTest.java
index b4305cb..4f52361 100644
--- a/src/test/java/org/onap/aai/sparky/synchronizer/SyncHelperTest.java
+++ b/src/test/java/org/onap/aai/sparky/synchronizer/SyncHelperTest.java
@@ -15,21 +15,23 @@ import org.onap.aai.sparky.viewandinspect.config.TierSupportUiConstants;
@RunWith(MockitoJUnitRunner.class)
public class SyncHelperTest {
- private SyncHelper syncHelper;
+ private SyncHelper syncHelper;
+
@BeforeClass
public static void initBeforeClass() throws IOException {
- String configHomePath = (new File(".").getCanonicalPath() + "/src/test/resources/sync").replace('\\', '/');
+ String configHomePath =
+ (new File(".").getCanonicalPath() + "/src/test/resources/sync").replace('\\', '/');
TierSupportUiConstants.AJSC_HOME = configHomePath;
TierSupportUiConstants.CONFIG_HOME = configHomePath;
}
-@Test
-public void testGetOxmModelLoader() throws Exception {
- syncHelper = new SyncHelper(new OxmModelLoader());
- OxmModelLoader oxmLoader = new OxmModelLoader();
- syncHelper.setOxmModelLoader(oxmLoader);
- assertEquals(oxmLoader, syncHelper.getOxmModelLoader());
-}
+ @Test
+ public void testGetOxmModelLoader() throws Exception {
+ syncHelper = new SyncHelper(new OxmModelLoader());
+ OxmModelLoader oxmLoader = new OxmModelLoader();
+ syncHelper.setOxmModelLoader(oxmLoader);
+ assertEquals(oxmLoader, syncHelper.getOxmModelLoader());
+ }
}
diff --git a/src/test/java/org/onap/aai/sparky/util/ElasticEntitySummarizer.java b/src/test/java/org/onap/aai/sparky/util/ElasticEntitySummarizer.java
index 171c163..7538c1b 100644
--- a/src/test/java/org/onap/aai/sparky/util/ElasticEntitySummarizer.java
+++ b/src/test/java/org/onap/aai/sparky/util/ElasticEntitySummarizer.java
@@ -44,6 +44,49 @@ import org.onap.aai.sparky.synchronizer.config.TaskProcessorConfig;
public class ElasticEntitySummarizer {
private RestDataProvider syncAdapter;
+ /**
+ * @return the syncAdapter
+ */
+ public RestDataProvider getSyncAdapter() {
+ return syncAdapter;
+ }
+
+ /**
+ * @param syncAdapter the syncAdapter to set
+ */
+ public void setSyncAdapter(RestDataProvider syncAdapter) {
+ this.syncAdapter = syncAdapter;
+ }
+
+ /**
+ * @return the elasticConfig
+ */
+ public ElasticSearchConfig getElasticConfig() {
+ return elasticConfig;
+ }
+
+ /**
+ * @param elasticConfig the elasticConfig to set
+ */
+ public void setElasticConfig(ElasticSearchConfig elasticConfig) {
+ this.elasticConfig = elasticConfig;
+ }
+
+ /**
+ * @return the entityCounters
+ */
+ public Map<String, AtomicInteger> getEntityCounters() {
+ return entityCounters;
+ }
+
+ /**
+ * @param entityCounters the entityCounters to set
+ */
+ public void setEntityCounters(Map<String, AtomicInteger> entityCounters) {
+ this.entityCounters = entityCounters;
+ }
+
+
private ElasticSearchConfig elasticConfig;
private Map<String, AtomicInteger> entityCounters;
@@ -150,24 +193,4 @@ public class ElasticEntitySummarizer {
}
-
-
- /**
- * The main method.
- *
- * @param args the arguments
- * @throws ElasticSearchOperationException the elastic search operation exception
- */
- public static void main(String[] args) throws ElasticSearchOperationException {
-
-
- // ElasticEntitySummarizer summarizer = new ElasticEntitySummarizer();
- // summarizer.enumerateEntities();
-
-
-
- }
-
-
-
}
diff --git a/src/test/java/org/onap/aai/sparky/util/LogValidator.java b/src/test/java/org/onap/aai/sparky/util/LogValidator.java
index a16a586..3ef8278 100644
--- a/src/test/java/org/onap/aai/sparky/util/LogValidator.java
+++ b/src/test/java/org/onap/aai/sparky/util/LogValidator.java
@@ -59,6 +59,13 @@ public class LogValidator {
}
/**
+ * @param logger the logger to set
+ */
+ public void setLogger(CaptureLoggerAppender logger) {
+ this.logger = logger;
+ }
+
+ /**
* Dump and count logs.
*
* @param logToConsole the log to console
diff --git a/src/test/java/org/onap/aai/sparky/util/ModelLoaderTester.java b/src/test/java/org/onap/aai/sparky/util/ModelLoaderTester.java
deleted file mode 100644
index ecad636..0000000
--- a/src/test/java/org/onap/aai/sparky/util/ModelLoaderTester.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-* ============LICENSE_START=======================================================
-* SPARKY (AAI UI service)
-* ================================================================================
-* Copyright © 2017 AT&T Intellectual Property.
-* Copyright © 2017 Amdocs
-* 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=========================================================
-*
-* ECOMP and OpenECOMP are trademarks
-* and service marks of AT&T Intellectual Property.
-*/
-
-package org.onap.aai.sparky.util;
-
-import org.onap.aai.sparky.config.oxm.OxmModelLoader;
-
-/**
- * The Class ModelLoaderTester.
- */
-public class ModelLoaderTester {
-
- /**
- * The main method.
- *
- * @param args the arguments
- */
- public static void main(String[] args) {
- System.getProperties().put("AJSC_HOME", "d:\\oxm\\");
-
- OxmModelLoader loader = OxmModelLoader.getInstance();
- }
-
-}
diff --git a/src/test/java/org/onap/aai/sparky/util/UtilPojoTest.java b/src/test/java/org/onap/aai/sparky/util/UtilPojoTest.java
new file mode 100644
index 0000000..52e1f52
--- /dev/null
+++ b/src/test/java/org/onap/aai/sparky/util/UtilPojoTest.java
@@ -0,0 +1,43 @@
+package org.onap.aai.sparky.util;
+
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.openpojo.reflection.PojoClass;
+import com.openpojo.reflection.filters.FilterChain;
+import com.openpojo.reflection.filters.FilterClassName;
+import com.openpojo.reflection.impl.PojoClassFactory;
+import com.openpojo.validation.Validator;
+import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.rule.impl.GetterMustExistRule;
+import com.openpojo.validation.rule.impl.SetterMustExistRule;
+import com.openpojo.validation.test.impl.GetterTester;
+import com.openpojo.validation.test.impl.SetterTester;
+
+public class UtilPojoTest {
+ private String packageName = "org.onap.aai.sparky.util";
+ private List<PojoClass> pojoClasses;
+
+ @Before
+ public void setup() {
+ // Get all classes recursively under package
+ FilterChain filterChainByClassName =
+ new FilterChain(new FilterClassName("\\w*KeystoreBuilder$"), new FilterClassName("\\w*savingTrustManager$"));
+
+ pojoClasses = PojoClassFactory.getPojoClassesRecursively(packageName, filterChainByClassName);
+ }
+
+ @Test
+ public void validate() {
+ Validator validator = ValidatorBuilder.create()
+ .with(new SetterMustExistRule(),
+ new GetterMustExistRule())
+ .with(new SetterTester(),
+ new GetterTester())
+ .build();
+ validator.validate(pojoClasses);
+ }
+
+}
diff --git a/src/test/java/org/onap/aai/sparky/viewandinspect/ActiveInventoryNodeTester.java b/src/test/java/org/onap/aai/sparky/viewandinspect/ActiveInventoryNodeTester.java
index 911de51..9dd23b5 100644
--- a/src/test/java/org/onap/aai/sparky/viewandinspect/ActiveInventoryNodeTester.java
+++ b/src/test/java/org/onap/aai/sparky/viewandinspect/ActiveInventoryNodeTester.java
@@ -352,28 +352,4 @@ public class ActiveInventoryNodeTester {
// }
}
-
-
-
- /**
- * The main method.
- *
- * @param args the arguments
- * @throws JsonProcessingException the json processing exception
- * @throws IOException Signals that an I/O exception has occurred.
- */
- public static void main(String[] args) throws JsonProcessingException, IOException {
-
- System.getProperties().setProperty("AJSC_HOME", "d:\\3\\");
- ActiveInventoryNodeTester tester = new ActiveInventoryNodeTester();
- // tester.doTest2(true);
-
- tester.parseDirectSelfLinkJsonResponse(DIRECT_COMPLEX_SELF_LINK_JSON_RESPONSE);
- System.out.println("---");
- tester.parseDirectSelfLinkJsonResponse(DIRECT_PSERVER_SELF_LINK_JSON_RESPONSE);
-
-
-
- }
-
}
diff --git a/src/test/java/org/onap/aai/sparky/viewandinspect/SelfLinkNodeCollectorTester.java b/src/test/java/org/onap/aai/sparky/viewandinspect/SelfLinkNodeCollectorTester.java
deleted file mode 100644
index 41efbab..0000000
--- a/src/test/java/org/onap/aai/sparky/viewandinspect/SelfLinkNodeCollectorTester.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
-* ============LICENSE_START=======================================================
-* SPARKY (AAI UI service)
-* ================================================================================
-* Copyright © 2017 AT&T Intellectual Property.
-* Copyright © 2017 Amdocs
-* 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=========================================================
-*
-* ECOMP and OpenECOMP are trademarks
-* and service marks of AT&T Intellectual Property.
-*/
-
-package org.onap.aai.sparky.viewandinspect;
-
-import org.onap.aai.sparky.config.oxm.OxmModelLoader;
-import org.onap.aai.sparky.viewandinspect.entity.ActiveInventoryNode;
-import org.onap.aai.sparky.viewandinspect.services.VisualizationContext;
-
-/**
- * The Class SelfLinkNodeCollectorTester.
- */
-public class SelfLinkNodeCollectorTester {
-
- /**
- * The main method.
- *
- * @param args the arguments
- * @throws Exception the exception
- */
- public static void main(String[] args) throws Exception {
- // TODO Auto-generated method stub
-
- System.getProperties().setProperty("AJSC_HOME", "d:\\3\\");
- //VisualizationContext collector = new VisualizationContext(OxmModelLoader.getInstance());
-
- /*
- * This is a good test of the LinkResolverServer when we are ready
- */
-
- ActiveInventoryNode ain = new ActiveInventoryNode();
- ain.setSelfLink(
- "https://localhost:9292/aai/v7/network/generic-vnfs/generic-vnf/d2f661e7-d6a0-43b5-979f-720803396a70/");
- ain.setEntityType("generic-vnf");
-
- /*
- * collector.collectSelfLinks(ain, 1, "generic-vnf",
- * "generic-vnf.d2f661e7-d6a0-43b5-979f-720803396a70");
- */
-
- // collector.shutdown();
-
- ain.dumpNodeTree(true);
-
- }
-
-}