summaryrefslogtreecommitdiffstats
path: root/src/test/java
diff options
context:
space:
mode:
authorArul.Nambi <arul.nambi@amdocs.com>2017-10-10 11:09:06 -0400
committerArul.Nambi <arul.nambi@amdocs.com>2017-10-10 11:10:17 -0400
commitdb2e2b074eeea255a798a684313453d260b4d682 (patch)
tree4d6f483d22c238617789443f156bd25bdd1c28fb /src/test/java
parent6ec1f2e784928e9391381608e40df77432c4255d (diff)
Increase junit coverage
Issue-ID: AAI-429 Change-Id: Ifde57eee0857509ae223a6399cee8601af58ec39 Signed-off-by: Arul.Nambi <arul.nambi@amdocs.com>
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/onap/aai/sparky/dal/rest/RestClientBuilderTest.java12
-rw-r--r--src/test/java/org/onap/aai/sparky/synchronizer/SyncControllerBuilder.java20
-rw-r--r--src/test/java/org/onap/aai/sparky/synchronizer/SyncHelperTest.java47
-rw-r--r--src/test/java/org/onap/aai/sparky/synchronizer/config/SynchronizerConfigurationTest.java400
-rw-r--r--src/test/java/org/onap/aai/sparky/synchronizer/entity/AggregationSuggestionEntityTest.java69
-rw-r--r--src/test/java/org/onap/aai/sparky/util/NodeUtilsTest.java18
6 files changed, 536 insertions, 30 deletions
diff --git a/src/test/java/org/onap/aai/sparky/dal/rest/RestClientBuilderTest.java b/src/test/java/org/onap/aai/sparky/dal/rest/RestClientBuilderTest.java
index 4dbcdea..4d10c6a 100644
--- a/src/test/java/org/onap/aai/sparky/dal/rest/RestClientBuilderTest.java
+++ b/src/test/java/org/onap/aai/sparky/dal/rest/RestClientBuilderTest.java
@@ -41,6 +41,7 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
import org.onap.aai.sparky.dal.rest.RestClientBuilder;
import org.onap.aai.sparky.security.SecurityContextFactory;
import org.powermock.modules.junit4.PowerMockRunner;
@@ -50,20 +51,11 @@ import ch.qos.logback.classic.Level;
/**
* The Class RestClientBuilderTest.
*/
-@RunWith(PowerMockRunner.class)
+@RunWith(MockitoJUnitRunner.class)
public class RestClientBuilderTest {
/**
- * Inits the.
- *
- * @throws Exception the exception
- */
- @Before
- public void init() throws Exception {
- }
-
- /**
* Basic construction test.
*
* @throws Exception the exception
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 523f893..bcd0c9a 100644
--- a/src/test/java/org/onap/aai/sparky/synchronizer/SyncControllerBuilder.java
+++ b/src/test/java/org/onap/aai/sparky/synchronizer/SyncControllerBuilder.java
@@ -38,8 +38,6 @@ import org.onap.aai.sparky.dal.rest.RestfulDataAccessor;
import org.onap.aai.sparky.synchronizer.AutosuggestionSynchronizer;
import org.onap.aai.sparky.synchronizer.CrossEntityReferenceSynchronizer;
import org.onap.aai.sparky.synchronizer.ElasticSearchIndexCleaner;
-import org.onap.aai.sparky.synchronizer.GeoSynchronizer;
-import org.onap.aai.sparky.synchronizer.HistoricalEntitySummarizer;
import org.onap.aai.sparky.synchronizer.IndexCleaner;
import org.onap.aai.sparky.synchronizer.IndexIntegrityValidator;
import org.onap.aai.sparky.synchronizer.SearchableEntitySynchronizer;
@@ -142,17 +140,6 @@ public class SyncControllerBuilder {
syncController.registerIndexValidator(entityCounterHistoryValidator);
-
- //////
-
-
-
- HistoricalEntitySummarizer historicalSummarizer =
- new HistoricalEntitySummarizer(esConfig.getEntityCountHistoryIndex());
- historicalSummarizer.setAaiDataProvider(aaiAdapter);
- historicalSummarizer.setEsDataProvider(esAdapter);
- syncController.registerEntitySynchronizer(historicalSummarizer);
-
////
/*
@@ -235,13 +222,6 @@ public class SyncControllerBuilder {
syncController.registerIndexValidator(entitySearchIndexValidator);
- //////
-
- GeoSynchronizer geoSync = new GeoSynchronizer("topographysearchindex-localhost");
- geoSync.setAaiDataProvider(aaiAdapter);
- geoSync.setEsDataProvider(esAdapter);
- syncController.registerEntitySynchronizer(geoSync);
-
////
/*
diff --git a/src/test/java/org/onap/aai/sparky/synchronizer/SyncHelperTest.java b/src/test/java/org/onap/aai/sparky/synchronizer/SyncHelperTest.java
new file mode 100644
index 0000000..55688d9
--- /dev/null
+++ b/src/test/java/org/onap/aai/sparky/synchronizer/SyncHelperTest.java
@@ -0,0 +1,47 @@
+package org.onap.aai.sparky.synchronizer;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.aai.sparky.config.oxm.OxmModelLoader;
+import org.onap.aai.sparky.dal.aai.config.ActiveInventoryConfig;
+import org.onap.aai.sparky.dal.aai.config.ActiveInventorySslConfig;
+import org.onap.aai.sparky.dal.elasticsearch.config.ElasticSearchConfig;
+import org.onap.aai.sparky.synchronizer.config.SynchronizerConfiguration;
+import org.onap.aai.sparky.synchronizer.config.TaskProcessorConfig;
+import org.onap.aai.sparky.util.Encryptor;
+import org.onap.aai.sparky.viewandinspect.config.TierSupportUiConstants;
+import org.junit.*;
+import static org.junit.Assert.*;
+import org.onap.aai.sparky.synchronizer.SyncHelper;
+
+@RunWith(MockitoJUnitRunner.class)
+public class SyncHelperTest {
+
+ private SyncHelper syncHelper;
+ @BeforeClass
+ public static void initBeforeClass() throws IOException {
+ 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());
+}
+
+}
diff --git a/src/test/java/org/onap/aai/sparky/synchronizer/config/SynchronizerConfigurationTest.java b/src/test/java/org/onap/aai/sparky/synchronizer/config/SynchronizerConfigurationTest.java
new file mode 100644
index 0000000..5f3bed9
--- /dev/null
+++ b/src/test/java/org/onap/aai/sparky/synchronizer/config/SynchronizerConfigurationTest.java
@@ -0,0 +1,400 @@
+package org.onap.aai.sparky.synchronizer.config;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Calendar;
+import java.util.Locale;
+import java.util.Properties;
+import java.util.TimeZone;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class SynchronizerConfigurationTest {
+
+ private SynchronizerConfiguration config;
+
+ private Properties generateTestProperties() {
+
+ Properties props = new Properties();
+
+ props.put("synchronizer.syncTask.initialDelayInMs", "60000");
+ props.put("synchronizer.syncTask.taskFrequencyInDay", "2");
+ props.put("synchronizer.syncTask.startTimestamp", "05:00:00 UTC+00:00");
+ props.put("synchronizer.historicalEntitySummarizerEnabled", "true");
+ props.put("synchronizer.historicalEntitySummarizedFrequencyInMinutes", "5");
+ props.put("synchronizer.resolver.progressLogFrequencyInMs", "60000");
+ props.put("synchronizer.resolver.queueMonitorFrequencyInMs", "1000");
+ props.put("synchronizer.resolver.displayVerboseQueueManagerStats", "false");
+
+ props.put("synchronizer.indexIntegrityValidator.enabled", "false");
+ props.put("synchronizer.indexIntegrityValidatorFrequencyInMs", "3600000");
+ props.put("synchronizer.scrollContextTimeToLiveInMinutes", "5");
+ props.put("synchronizer.numScrollContextItemsToRetrievePerRequest", "5000");
+ props.put("synchronizer.suppressResourceNotFoundErrors", "true");
+ props.put("synchronizer.applyNodesOnlyModifier", "false");
+ props.put("synchronizer.autosuggestSynchronizationEnabled", "true");
+
+ return props;
+ }
+
+
+ @Before
+ public void init() throws Exception {
+
+ config = new SynchronizerConfiguration(generateTestProperties());
+
+ }
+
+ @Test
+ public void validateAccessors() {
+
+ assertEquals(60000, config.getSyncTaskInitialDelayInMs());
+ assertEquals(2, config.getSyncTaskFrequencyInDay());
+ assertEquals("05:00:00 UTC+00:00", config.getSyncTaskStartTime());
+ assertEquals(5, config.getSyncTaskStartTimeHr());
+ assertEquals(0, config.getSyncTaskStartTimeMin());
+ assertEquals(0, config.getSyncTaskStartTimeSec());
+ assertEquals(true, config.isAutosuggestSynchronizationEnabled());
+ assertEquals(false, config.isConfigDisabledForInitialSync() );
+ assertEquals(true, config.isConfigOkForPeriodicSync());
+ assertEquals(true, config.isConfigOkForStartupSync());
+ assertEquals(false, config.isDisplayVerboseQueueManagerStats());
+ assertEquals(false, config.isIndexIntegrityValidatorEnabled());
+ assertEquals(false, config.isNodesOnlyModifierEnabled());
+ assertEquals(true, config.isResourceNotFoundErrorsSupressed());
+ assertEquals(5000, config.getNumScrollContextItemsToRetrievePerRequest());
+ assertEquals(5, config.getScrollContextTimeToLiveInMinutes());
+ assertEquals("GMT+00:00", config.getSyncTaskStartTimeTimeZone());
+ assertEquals(0, config.getSyncTaskFrequencyInMs());
+ assertEquals(60000, config.getResolverProgressLogFrequencyInMs());
+ assertEquals(1000, config.getResolverQueueMonitorFrequencyInMs());
+ assertEquals(3600000, config.getIndexIntegrityValidatorFrequencyInMs());
+ assertTrue(config.toString().startsWith("SynchronizerConfiguration"));
+
+
+ config.setSyncTaskInitialDelayInMs(1234);
+ assertEquals(1234, config.getSyncTaskInitialDelayInMs());
+
+ config.setSyncTaskFrequencyInDay(5);
+ assertEquals(5, config.getSyncTaskFrequencyInDay());
+ config.setSyncTaskStartTime("06:10:22 UTC+00:00");
+ assertEquals("06:10:22 UTC+00:00", config.getSyncTaskStartTime());
+
+ config.setSyncTaskStartTimeHr(6);
+ assertEquals(6, config.getSyncTaskStartTimeHr());
+
+ config.setSyncTaskStartTimeMin(10);
+ assertEquals(10, config.getSyncTaskStartTimeMin());
+
+ config.setSyncTaskStartTimeSec(22);
+ assertEquals(22, config.getSyncTaskStartTimeSec());
+
+ config.setAutosuggestSynchronizationEnabled(false);
+ assertEquals(false, config.isAutosuggestSynchronizationEnabled());
+
+ config.setDisplayVerboseQueueManagerStats(true);
+ assertEquals(true, config.isDisplayVerboseQueueManagerStats());
+
+
+ config.setIndexIntegrityValidatorEnabled(true);
+ assertEquals(true, config.isIndexIntegrityValidatorEnabled());
+
+ config.setNodesOnlyModifierEnabled(true);
+ assertEquals(true, config.isNodesOnlyModifierEnabled());
+
+ config.setResourceNotFoundErrorsSupressed(false);
+ assertEquals(false, config.isResourceNotFoundErrorsSupressed());
+
+ config.setNumScrollContextItemsToRetrievePerRequest(1234);
+ assertEquals(1234, config.getNumScrollContextItemsToRetrievePerRequest());
+
+ config.setScrollContextTimeToLiveInMinutes(11);
+ assertEquals(11, config.getScrollContextTimeToLiveInMinutes());
+
+
+ config.setSyncTaskStartTimeTimeZone("EST");
+ assertEquals("EST", config.getSyncTaskStartTimeTimeZone());
+
+ config.setSyncTaskFrequencyInMs(1221);
+ assertEquals(1221, config.getSyncTaskFrequencyInMs());
+
+ config.setResolverProgressLogFrequencyInMs(1111);
+ assertEquals(1111, config.getResolverProgressLogFrequencyInMs());
+
+ config.setResolverQueueMonitorFrequencyInMs(1111);
+ assertEquals(1111, config.getResolverQueueMonitorFrequencyInMs());
+
+ config.setIndexIntegrityValidatorFrequencyInMs(5555);
+ assertEquals(5555, config.getIndexIntegrityValidatorFrequencyInMs());
+
+ config.setConfigOkForPeriodicSync(false);
+ assertEquals(false, config.isConfigOkForPeriodicSync());
+
+ config.setConfigOkForStartupSync(false);
+ assertEquals(false, config.isConfigOkForStartupSync());
+
+
+ }
+
+ @Test
+ public void validateFirstSyncTimeCalculation_taskFrequencyZeroDays() {
+
+ Calendar syncThresholdTime = Calendar.getInstance(TimeZone.getTimeZone("EST"),Locale.CANADA);
+
+ // set year, month, day, hour, minute, second
+ syncThresholdTime.set(2017,2,1,0,0,0); // 00:00 on 1-Feb-2017
+
+
+ Calendar timeNow = Calendar.getInstance(TimeZone.getTimeZone("EST"),Locale.CANADA);
+
+ // set year, month, day, hour, minute, second
+ timeNow.set(2017,2,1,0,0,0); // 00:00 on 1-Feb-2017
+
+ assertEquals( 0, config.getNextSyncTime(syncThresholdTime, timeNow.getTimeInMillis(), 0));
+
+ }
+
+ @Test
+ public void validateFirstSyncTimeCalculation_timeNowLessThanSyncTimeBoundary() {
+
+ Calendar syncThresholdTime = Calendar.getInstance(TimeZone.getTimeZone("EST"),Locale.CANADA);
+
+ // 06:00 on 1-Feb-2017
+ syncThresholdTime.set(2017,2,1,6,0,0);
+
+ Calendar timeNow = Calendar.getInstance(TimeZone.getTimeZone("EST"),Locale.CANADA);
+
+ // set year, month, day, hour, minute, second
+ timeNow.set(2017,2,1,0,0,0); // 00:00 on 1-Feb-2017
+
+ // First sync time is the 06:00 am threshold time
+ assertEquals( syncThresholdTime.getTimeInMillis(), config.getNextSyncTime(syncThresholdTime, timeNow.getTimeInMillis(), 1*86400));
+
+ }
+
+ @Test
+ public void validateFirstSyncTimeCalculation_timeNowEqualsSyncTimeBoundary() {
+
+ Calendar syncThresholdTime = Calendar.getInstance(TimeZone.getTimeZone("EST"),Locale.CANADA);
+
+ // 06:00 on 1-Feb-2017
+ syncThresholdTime.set(2017,2,1,6,0,0);
+
+ Calendar timeNow = Calendar.getInstance(TimeZone.getTimeZone("EST"),Locale.CANADA);
+
+ // set year, month, day, hour, minute, second
+ timeNow.set(2017,2,1,6,0,0); // 00:00 on 1-Feb-2017
+
+ // First sync time is the 06:00 am threshold time
+ assertEquals( (syncThresholdTime.getTimeInMillis()/1000), (config.getNextSyncTime(syncThresholdTime, timeNow.getTimeInMillis(), 1*86400)/1000));
+
+ }
+
+ @Test
+ public void validateFirstSyncTimeCalculation_timeNowGreaterThanSyncTimeBoundary() {
+
+ Calendar syncThresholdTime = Calendar.getInstance(TimeZone.getTimeZone("EST"),Locale.CANADA);
+
+ // 06:00 on 1-Feb-2017
+ syncThresholdTime.set(2017,2,1,6,0,0);
+
+ Calendar timeNow = Calendar.getInstance(TimeZone.getTimeZone("EST"),Locale.CANADA);
+
+ // set year, month, day, hour, minute, second
+ timeNow.set(2017,2,1,8,0,0); // 00:00 on 1-Feb-2017
+
+ // First sync time is 1 full sync period past the sync threshold time
+ assertEquals( 86400000 + syncThresholdTime.getTimeInMillis(), config.getNextSyncTime(syncThresholdTime, timeNow.getTimeInMillis(), 1*86400));
+
+ }
+
+/* @Test
+ public void validateDefaultPeriodicInitialSyncDelay_dailySync_timeNowAtMidnight() {
+
+ config.setSyncTaskStartTimeTimeZone("EST");
+ config.setSyncTaskStartTimeHr(6);
+ config.setSyncTaskStartTimeMin(0);
+ config.setSyncTaskStartTimeSec(0);
+ config.setSyncTaskFrequencyInDay(1);
+ config.setSyncTaskInitialDelayInMs(60000);
+
+ Calendar timeNow = Calendar.getInstance(TimeZone.getTimeZone("EST"));
+
+ // set year, month, day, hour, minute, second
+ timeNow.set(Calendar.AM_PM, Calendar.AM);
+ timeNow.set(Calendar.HOUR, 0);
+ timeNow.set(Calendar.MINUTE, 0);
+ timeNow.set(Calendar.SECOND, 0);
+
+ // First sync time is 6 hours from midnight
+ assertEquals( 6*3600*1000, config.getDefaultInitialSyncDelayInMs(timeNow));
+
+ }*/
+
+ @Test
+ public void validateDefaultPeriodicInitialSyncDelay_dailySync_timeNowAt4AM() {
+
+ config.setSyncTaskStartTimeTimeZone("EST");
+ config.setSyncTaskStartTimeHr(6);
+ config.setSyncTaskStartTimeMin(0);
+ config.setSyncTaskStartTimeSec(0);
+ config.setSyncTaskFrequencyInDay(1);
+ config.setSyncTaskInitialDelayInMs(60000);
+
+ Calendar timeNow = Calendar.getInstance(TimeZone.getTimeZone("EST"));
+
+ // set year, month, day, hour, minute, second
+ timeNow.set(Calendar.AM_PM, Calendar.AM);
+ timeNow.set(Calendar.HOUR, 4);
+ timeNow.set(Calendar.MINUTE, 0);
+ timeNow.set(Calendar.SECOND, 0);
+
+ // round time to minutes to avoid millisecond alignment variance
+ assertEquals(2 * 3600, (config.getDefaultInitialSyncDelayInMs(timeNow)) / 1000);
+
+ }
+
+ @Test
+ public void validateDefaultPeriodicInitialSyncDelay_dailySync_timeNowAt6AM() {
+
+ config.setSyncTaskStartTimeTimeZone("EST");
+ config.setSyncTaskStartTimeHr(6);
+ config.setSyncTaskStartTimeMin(0);
+ config.setSyncTaskStartTimeSec(0);
+ config.setSyncTaskFrequencyInDay(1);
+ config.setSyncTaskInitialDelayInMs(60000);
+
+ Calendar timeNow = Calendar.getInstance(TimeZone.getTimeZone("EST"));
+
+ // set year, month, day, hour, minute, second
+ timeNow.set(Calendar.AM_PM, Calendar.AM);
+ timeNow.set(Calendar.HOUR, 6);
+ timeNow.set(Calendar.MINUTE, 0);
+ timeNow.set(Calendar.SECOND, 0);
+
+ // First sync time is now with 60 seconds from now
+ assertEquals( 60000, config.getDefaultInitialSyncDelayInMs(timeNow));
+
+ }
+
+ @Test
+ public void validateDefaultPeriodicInitialSyncDelay_dailySync_timeNowAt10PM() {
+
+ config.setSyncTaskStartTimeTimeZone("EST");
+ config.setSyncTaskStartTimeHr(6);
+ config.setSyncTaskStartTimeMin(0);
+ config.setSyncTaskStartTimeSec(0);
+ config.setSyncTaskFrequencyInDay(1);
+ config.setSyncTaskInitialDelayInMs(60000);
+
+ Calendar timeNow = Calendar.getInstance(TimeZone.getTimeZone("EST"));
+
+ // set year, month, day, hour, minute, second
+ timeNow.set(Calendar.AM_PM, Calendar.PM);
+ timeNow.set(Calendar.HOUR, 10);
+ timeNow.set(Calendar.MINUTE, 0);
+ timeNow.set(Calendar.SECOND, 0);
+
+ // First sync time is now 1 sync period delayed. The time delay before
+ // the initial sync should now be 8 hours, assuming 10PM is the current time.
+ assertEquals( 8*3600, (config.getDefaultInitialSyncDelayInMs(timeNow)/1000));
+
+ }
+
+/* @Test
+ public void validateDefaultPeriodicInitialSyncDelay_weeklySync_timeNowAtMidnight() {
+
+ config.setSyncTaskStartTimeTimeZone("EST");
+ config.setSyncTaskStartTimeHr(6);
+ config.setSyncTaskStartTimeMin(0);
+ config.setSyncTaskStartTimeSec(0);
+ config.setSyncTaskFrequencyInDay(7);
+ config.setSyncTaskInitialDelayInMs(60000);
+
+ Calendar timeNow = Calendar.getInstance(TimeZone.getTimeZone("EST"));
+
+ // set year, month, day, hour, minute, second
+ timeNow.set(Calendar.AM_PM, Calendar.AM);
+ timeNow.set(Calendar.HOUR, 0);
+ timeNow.set(Calendar.MINUTE, 0);
+ timeNow.set(Calendar.SECOND, 0);
+
+ // First sync time is 6 hours from midnight
+ assertTrue(6*3600*1000 >= config.getDefaultInitialSyncDelayInMs(timeNow));
+
+ }*/
+
+ @Test
+ public void validateDefaultPeriodicInitialSyncDelay_weeklySync_timeNowAt4AM() {
+
+ config.setSyncTaskStartTimeTimeZone("EST");
+ config.setSyncTaskStartTimeHr(6);
+ config.setSyncTaskStartTimeMin(0);
+ config.setSyncTaskStartTimeSec(0);
+ config.setSyncTaskFrequencyInDay(7);
+ config.setSyncTaskInitialDelayInMs(60000);
+
+ Calendar timeNow = Calendar.getInstance(TimeZone.getTimeZone("EST"));
+
+ // set year, month, day, hour, minute, second
+ timeNow.set(Calendar.AM_PM, Calendar.AM);
+ timeNow.set(Calendar.HOUR, 4);
+ timeNow.set(Calendar.MINUTE, 0);
+ timeNow.set(Calendar.SECOND, 0);
+
+ // round time to minutes to avoid millisecond alignment variance
+ assertEquals(2 * 3600, (config.getDefaultInitialSyncDelayInMs(timeNow)) / 1000);
+
+ }
+
+ @Test
+ public void validateDefaultPeriodicInitialSyncDelay_weeklySync_timeNowAt6AM() {
+
+ config.setSyncTaskStartTimeTimeZone("EST");
+ config.setSyncTaskStartTimeHr(6);
+ config.setSyncTaskStartTimeMin(0);
+ config.setSyncTaskStartTimeSec(0);
+ config.setSyncTaskFrequencyInDay(7);
+ config.setSyncTaskInitialDelayInMs(60000);
+
+ Calendar timeNow = Calendar.getInstance(TimeZone.getTimeZone("EST"));
+
+ // set year, month, day, hour, minute, second
+ timeNow.set(Calendar.AM_PM, Calendar.AM);
+ timeNow.set(Calendar.HOUR, 6);
+ timeNow.set(Calendar.MINUTE, 0);
+ timeNow.set(Calendar.SECOND, 0);
+
+ // First sync time is now with 60 seconds from now
+ assertEquals( 60000, config.getDefaultInitialSyncDelayInMs(timeNow));
+
+ }
+
+ @Test
+ public void validateDefaultPeriodicInitialSyncDelay_weeklySync_timeNowAt10PM() {
+
+ config.setSyncTaskStartTimeTimeZone("EST");
+ config.setSyncTaskStartTimeHr(6);
+ config.setSyncTaskStartTimeMin(0);
+ config.setSyncTaskStartTimeSec(0);
+ config.setSyncTaskFrequencyInDay(7);
+ config.setSyncTaskInitialDelayInMs(60000);
+
+ Calendar timeNow = Calendar.getInstance(TimeZone.getTimeZone("EST"));
+
+ // set year, month, day, hour, minute, second
+ timeNow.set(Calendar.AM_PM, Calendar.PM);
+ timeNow.set(Calendar.HOUR, 10);
+ timeNow.set(Calendar.MINUTE, 0);
+ timeNow.set(Calendar.SECOND, 0);
+
+ // First sync time is now 1 sync period delayed. The time delay before
+ // the initial sync should now be 8 hours + 24*6 days, assuming 10PM is the current time.
+ assertEquals( (8+(6*24))*3600, (config.getDefaultInitialSyncDelayInMs(timeNow)/1000));
+
+ }
+
+
+}
diff --git a/src/test/java/org/onap/aai/sparky/synchronizer/entity/AggregationSuggestionEntityTest.java b/src/test/java/org/onap/aai/sparky/synchronizer/entity/AggregationSuggestionEntityTest.java
new file mode 100644
index 0000000..5b945cf
--- /dev/null
+++ b/src/test/java/org/onap/aai/sparky/synchronizer/entity/AggregationSuggestionEntityTest.java
@@ -0,0 +1,69 @@
+/**
+ * ============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.synchronizer.entity;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Scanner;
+
+import org.junit.Test;
+
+public class AggregationSuggestionEntityTest {
+ public String getResourceFileContents(String filePath) {
+ StringBuilder result = new StringBuilder("");
+
+ ClassLoader classLoader = getClass().getClassLoader();
+ File file = new File(classLoader.getResource(filePath).getFile());
+
+ try (Scanner scanner = new Scanner(file)) {
+ while (scanner.hasNextLine()) {
+ String line = scanner.nextLine();
+ result.append(line).append("\n");
+ }
+ scanner.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return result.toString();
+ }
+
+ @Test
+ public void testGetIndexDocumentJson() {
+ AggregationSuggestionEntity aggregationSuggestionEntity = new AggregationSuggestionEntity();
+
+ String expectedFilterListPayload = getResourceFileContents(
+ "sync/entity/AggregationSuggestionEntity_getIndexDocumentJson_expected.json");
+
+ assertTrue(
+ aggregationSuggestionEntity.getIndexDocumentJson().contains(expectedFilterListPayload.trim()));
+ }
+}
diff --git a/src/test/java/org/onap/aai/sparky/util/NodeUtilsTest.java b/src/test/java/org/onap/aai/sparky/util/NodeUtilsTest.java
index 0388b1c..9329d9a 100644
--- a/src/test/java/org/onap/aai/sparky/util/NodeUtilsTest.java
+++ b/src/test/java/org/onap/aai/sparky/util/NodeUtilsTest.java
@@ -29,6 +29,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail;
import java.util.ArrayList;
@@ -471,6 +472,23 @@ public class NodeUtilsTest {
}
/**
+ * Test isNumeric expect true
+ */
+ @Test
+ public void test_isNumeric_expectFalse(){
+ String invalidNumber="number";
+ assertFalse(NodeUtils.isNumeric(invalidNumber));
+ }
+
+ /**
+ * Test isNumeric expect true
+ */
+ @Test
+ public void test_isNumeric_expectTrue(){
+ String validNumber="123";
+ assertTrue(NodeUtils.isNumeric(validNumber));
+ }
+ /**
* test calculate edit attributes urls
*/
@Test