Increase junit coverage 21/18021/1
authorArul.Nambi <arul.nambi@amdocs.com>
Tue, 10 Oct 2017 17:36:50 +0000 (13:36 -0400)
committerArul.Nambi <arul.nambi@amdocs.com>
Tue, 10 Oct 2017 17:37:57 +0000 (13:37 -0400)
Issue-ID: AAI-429
Change-Id: I8cd6c89bf7abd2d4d0d78bbf25fe6e5b5de53224
Signed-off-by: Arul.Nambi <arul.nambi@amdocs.com>
21 files changed:
pom.xml
src/main/java/org/onap/aai/sparky/synchronizer/ElasticSearchIndexCleaner.java
src/main/java/org/onap/aai/sparky/synchronizer/SyncHelper.java
src/main/java/org/onap/aai/sparky/synchronizer/entity/AggregationEntity.java
src/main/java/org/onap/aai/sparky/synchronizer/entity/AggregationSuggestionEntity.java
src/main/java/org/onap/aai/sparky/synchronizer/entity/IndexableCrossEntityReference.java
src/main/java/org/onap/aai/sparky/synchronizer/entity/IndexableEntity.java
src/main/java/org/onap/aai/sparky/synchronizer/entity/MergableEntity.java
src/main/java/org/onap/aai/sparky/synchronizer/entity/ObjectIdCollection.java
src/main/java/org/onap/aai/sparky/synchronizer/entity/SearchableEntity.java
src/main/java/org/onap/aai/sparky/synchronizer/entity/SuggestionSearchEntity.java
src/main/java/org/onap/aai/sparky/synchronizer/entity/TransactionStorageType.java
src/test/java/org/onap/aai/sparky/analytics/AveragingRingBufferTest.java
src/test/java/org/onap/aai/sparky/analytics/HistogramSamplerTest.java
src/test/java/org/onap/aai/sparky/dal/rest/RestfulDataAccessorTest.java
src/test/java/org/onap/aai/sparky/inventory/GeoIndexDocumentTest.java
src/test/java/org/onap/aai/sparky/synchronizer/IndexDocumentTest.java
src/test/java/org/onap/aai/sparky/synchronizer/SyncHelperTest.java
src/test/java/org/onap/aai/sparky/synchronizer/entity/IndexableEntityTest.java [new file with mode: 0644]
src/test/java/org/onap/aai/sparky/viewandinspect/ViewAndInspectSearchRequestTest.java
src/test/java/org/onap/aai/sparky/viewandinspect/entity/EntityEntryTest.java

diff --git a/pom.xml b/pom.xml
index 4fdea22..01f35b9 100644 (file)
--- a/pom.xml
+++ b/pom.xml
                    <version>1.2.17</version>
                </dependency>
                
+               <dependency>
+                   <groupId>com.openpojo</groupId>
+                   <artifactId>openpojo</artifactId>
+                   <version>0.8.6</version>
+               </dependency>
+               
                <dependency>
                        <groupId>org.onap.portal.sdk</groupId>
                        <artifactId>epsdk-fw</artifactId>
index 74cb1cb..842a416 100644 (file)
@@ -145,8 +145,8 @@ public class ElasticSearchIndexCleaner implements IndexCleaner {
 
     if (sizeAfter > 0) {
 
-      Collection<String> presyncIds = before.getImportedObjectIds();
-      presyncIds.removeAll(after.getImportedObjectIds());
+      Collection<String> presyncIds = before.getImportedObjectIdsAsValues();
+      presyncIds.removeAll(after.getImportedObjectIdsAsValues());
 
       try {
         LOG.info(AaiUiMsgs.ES_SYNC_SELECTIVE_DELETE, indexName, indexType,
@@ -165,7 +165,7 @@ public class ElasticSearchIndexCleaner implements IndexCleaner {
 
           if (numItemsInBulkRequest >= this.numItemsToGetBulkRequest) {
             LOG.info(AaiUiMsgs.ES_BULK_DELETE, indexName, String.valueOf(bulkIds.getSize()));
-            OperationResult bulkDeleteResult = bulkDelete(bulkIds.getImportedObjectIds());
+            OperationResult bulkDeleteResult = bulkDelete(bulkIds.getImportedObjectIdsAsValues());
             // pegCountersForElasticBulkDelete(bulkDeleteResult);
             numItemsRemainingToBeDeleted -= numItemsInBulkRequest;
             numItemsInBulkRequest = 0;
@@ -175,7 +175,7 @@ public class ElasticSearchIndexCleaner implements IndexCleaner {
 
         if (numItemsRemainingToBeDeleted > 0) {
           LOG.info(AaiUiMsgs.ES_BULK_DELETE, indexName, String.valueOf(bulkIds.getSize()));
-          OperationResult bulkDeleteResult = bulkDelete(bulkIds.getImportedObjectIds());
+          OperationResult bulkDeleteResult = bulkDelete(bulkIds.getImportedObjectIdsAsValues());
           // pegCountersForElasticBulkDelete(bulkDeleteResult);
         }
 
index 3738acf..617eb08 100644 (file)
@@ -92,7 +92,15 @@ public class SyncHelper {
 
     private boolean isInitialSync;
 
-    /**
+    public boolean isInitialSync() {
+               return isInitialSync;
+       }
+
+       public void setInitialSync(boolean isInitialSync) {
+               this.isInitialSync = isInitialSync;
+       }
+
+       /**
      * Instantiates a new sync task.
      *
      * @param initialSync the initial sync
index ff22ba0..af8159a 100644 (file)
@@ -93,7 +93,35 @@ public class AggregationEntity extends IndexableEntity implements IndexDocument
     return rootNode.toString();
   }
 
-  @Override
+  /**
+   * @return the attributes
+   */
+  public Map<String, String> getAttributes() {
+    return attributes;
+  }
+
+  /**
+   * @param attributes the attributes to set
+   */
+  public void setAttributes(Map<String, String> attributes) {
+    this.attributes = attributes;
+  }
+
+  /**
+   * @return the mapper
+   */
+  public ObjectMapper getMapper() {
+    return mapper;
+  }
+
+  /**
+   * @param mapper the mapper to set
+   */
+  public void setMapper(ObjectMapper mapper) {
+    this.mapper = mapper;
+  }
+
+@Override
   public ObjectNode getBulkImportEntity() {
     // TODO Auto-generated method stub
     return null;
index d7755e2..145b23f 100644 (file)
@@ -35,6 +35,41 @@ import org.onap.aai.sparky.util.NodeUtils;
 public class AggregationSuggestionEntity extends IndexableEntity implements IndexDocument {
 
   private List<String> inputs = new ArrayList<String>();
+  /**
+   * @return the inputs
+   */
+  public List<String> getInputs() {
+    return inputs;
+  }
+
+  /**
+   * @param inputs the inputs to set
+   */
+  public void setInputs(List<String> inputs) {
+    this.inputs = inputs;
+  }
+
+  /**
+   * @return the mapper
+   */
+  public ObjectMapper getMapper() {
+    return mapper;
+  }
+
+  /**
+   * @param mapper the mapper to set
+   */
+  public void setMapper(ObjectMapper mapper) {
+    this.mapper = mapper;
+  }
+
+  /**
+   * @return the outputString
+   */
+  public String getOutputString() {
+    return outputString;
+  }
+
   private final String outputString = "VNFs";
   protected ObjectMapper mapper = new ObjectMapper();
   
index aa604fb..bb564f3 100644 (file)
@@ -38,7 +38,49 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
 public class IndexableCrossEntityReference extends IndexableEntity implements IndexDocument {
 
   protected String crossReferenceEntityValues;
-  protected ArrayList<String> crossEntityReferenceCollection = new ArrayList<String>();
+  /**
+ * @return the crossReferenceEntityValues
+ */
+  public String getCrossReferenceEntityValues() {
+    return crossReferenceEntityValues;
+  }
+
+  /**
+   * @param crossReferenceEntityValues the crossReferenceEntityValues to set
+   */
+  public void setCrossReferenceEntityValues(String crossReferenceEntityValues) {
+    this.crossReferenceEntityValues = crossReferenceEntityValues;
+  }
+
+  /**
+   * @return the crossEntityReferenceCollection
+   */
+  public ArrayList<String> getCrossEntityReferenceCollection() {
+    return crossEntityReferenceCollection;
+  }
+
+  /**
+   * @param crossEntityReferenceCollection the crossEntityReferenceCollection to set
+   */
+  public void setCrossEntityReferenceCollection(ArrayList<String> crossEntityReferenceCollection) {
+    this.crossEntityReferenceCollection = crossEntityReferenceCollection;
+  }
+
+/**
+ * @return the mapper
+ */
+public ObjectMapper getMapper() {
+       return mapper;
+}
+
+/**
+ * @param mapper the mapper to set
+ */
+public void setMapper(ObjectMapper mapper) {
+       this.mapper = mapper;
+}
+
+protected ArrayList<String> crossEntityReferenceCollection = new ArrayList<String>();
   protected ObjectMapper mapper = new ObjectMapper();
 
   /**
index 342f8df..4c9a5c6 100644 (file)
@@ -35,7 +35,43 @@ public abstract class IndexableEntity {
   protected String entityType;
   protected String entityPrimaryKeyValue;
   protected String lastmodTimestamp;
-  protected String link;
+
+  /**
+   * @return the lastmodTimestamp
+   */
+  public String getLastmodTimestamp() {
+    return lastmodTimestamp;
+  }
+
+  /**
+   * @param lastmodTimestamp the lastmodTimestamp to set
+   */
+  public void setLastmodTimestamp(String lastmodTimestamp) {
+    this.lastmodTimestamp = lastmodTimestamp;
+  }
+
+  /**
+   * @return the loader
+   */
+  public OxmModelLoader getLoader() {
+    return loader;
+  }
+
+  /**
+   * @param loader the loader to set
+   */
+  public void setLoader(OxmModelLoader loader) {
+    this.loader = loader;
+  }
+
+  /**
+   * @return the timestampFormat
+   */
+  public static String getTimestampFormat() {
+    return TIMESTAMP_FORMAT;
+  }
+
+protected String link;
   protected OxmModelLoader loader;
 
   private static final String TIMESTAMP_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
index 1935ed9..f709ee0 100644 (file)
@@ -35,6 +35,13 @@ public class MergableEntity {
   private Map<String, String> other = new HashMap<String, String>();
 
   /**
+ * @param other the other to set
+ */
+public void setOther(Map<String, String> other) {
+       this.other = other;
+}
+
+/**
    * Any.
    *
    * @return the map
@@ -44,7 +51,11 @@ public class MergableEntity {
     return other;
   }
 
-  /**
+  public Map<String, String> getOther() {
+       return other;
+}
+
+/**
    * Sets the.
    *
    * @param name the name
index e423934..e17c430 100644 (file)
@@ -34,9 +34,24 @@ public class ObjectIdCollection {
   protected ConcurrentHashMap<String, String> importedObjectIds =
       new ConcurrentHashMap<String, String>();
 
-  public Collection<String> getImportedObjectIds() {
-    return importedObjectIds.values();
-  }
+       /**
+        * @return the importedObjectIds
+        */
+       public ConcurrentHashMap<String, String> getImportedObjectIds() {
+               return importedObjectIds;
+       }
+
+       /**
+        * @param importedObjectIds
+        *            the importedObjectIds to set
+        */
+       public void setImportedObjectIds(ConcurrentHashMap<String, String> importedObjectIds) {
+               this.importedObjectIds = importedObjectIds;
+       }
+
+       public Collection<String> getImportedObjectIdsAsValues() {
+               return importedObjectIds.values();
+       }
 
   /**
    * Adds the object id.
index 46ef7f6..e7cfab1 100644 (file)
@@ -36,6 +36,48 @@ import org.onap.aai.sparky.util.NodeUtils;
  */
 public class SearchableEntity extends IndexableEntity implements IndexDocument {
   protected List<String> searchTagCollection = new ArrayList<String>();
+  /**
+   * @return the mapper
+   */
+  public ObjectMapper getMapper() {
+    return mapper;
+  }
+
+  /**
+   * @param mapper the mapper to set
+   */
+  public void setMapper(ObjectMapper mapper) {
+    this.mapper = mapper;
+  }
+
+  /**
+   * @param searchTagCollection the searchTagCollection to set
+   */
+  public void setSearchTagCollection(List<String> searchTagCollection) {
+    this.searchTagCollection = searchTagCollection;
+  }
+
+  /**
+   * @param searchTagIdCollection the searchTagIdCollection to set
+   */
+  public void setSearchTagIdCollection(List<String> searchTagIdCollection) {
+    this.searchTagIdCollection = searchTagIdCollection;
+  }
+
+  /**
+   * @param searchTags the searchTags to set
+   */
+  public void setSearchTags(String searchTags) {
+    this.searchTags = searchTags;
+  }
+
+  /**
+   * @param searchTagIDs the searchTagIDs to set
+   */
+  public void setSearchTagIDs(String searchTagIDs) {
+    this.searchTagIDs = searchTagIDs;
+  }
+
   protected List<String> searchTagIdCollection = new ArrayList<String>();
   protected ObjectMapper mapper = new ObjectMapper();
 
index 4f6188d..ffe92cf 100644 (file)
@@ -42,6 +42,77 @@ public class SuggestionSearchEntity extends IndexableEntity implements IndexDocu
   private String entityType;
   private List<String> suggestionConnectorWords = new ArrayList<String>();
   private List<String> suggestionAttributeTypes = new ArrayList<String>();
+  /**
+   * @return the suggestionAttributeTypes
+   */
+  public List<String> getSuggestionAttributeTypes() {
+    return suggestionAttributeTypes;
+  }
+
+  /**
+   * @param suggestionAttributeTypes the suggestionAttributeTypes to set
+   */
+  public void setSuggestionAttributeTypes(List<String> suggestionAttributeTypes) {
+    this.suggestionAttributeTypes = suggestionAttributeTypes;
+  }
+
+  /**
+   * @return the suggestionTypeAliases
+   */
+  public List<String> getSuggestionTypeAliases() {
+    return suggestionTypeAliases;
+  }
+
+  /**
+   * @param suggestionTypeAliases the suggestionTypeAliases to set
+   */
+  public void setSuggestionTypeAliases(List<String> suggestionTypeAliases) {
+    this.suggestionTypeAliases = suggestionTypeAliases;
+  }
+
+  /**
+   * @return the suggestableAttr
+   */
+  public List<String> getSuggestableAttr() {
+    return suggestableAttr;
+  }
+
+  /**
+   * @param suggestableAttr the suggestableAttr to set
+   */
+  public void setSuggestableAttr(List<String> suggestableAttr) {
+    this.suggestableAttr = suggestableAttr;
+  }
+
+  /**
+   * @return the outputString
+   */
+  public StringBuffer getOutputString() {
+    return outputString;
+  }
+
+  /**
+   * @param outputString the outputString to set
+   */
+  public void setOutputString(StringBuffer outputString) {
+    this.outputString = outputString;
+  }
+
+  /**
+   * @return the mapper
+   */
+  public ObjectMapper getMapper() {
+    return mapper;
+  }
+
+  /**
+   * @param mapper the mapper to set
+   */
+  public void setMapper(ObjectMapper mapper) {
+    this.mapper = mapper;
+  }
+
+
   private List<String> suggestionAttributeValues = new ArrayList<String>();
   private List<String> suggestionTypeAliases = new ArrayList<String>();
   private List<String> suggestionInputPermutations = new ArrayList<String>();
index 2f0ffa8..7bb131c 100644 (file)
@@ -30,7 +30,22 @@ public enum TransactionStorageType {
       "aaiOffline/active-inventory-query");
 
   private Integer index;
-  private String outputFolder;
+
+  /**
+   * @param index the index to set
+   */
+  public void setIndex(Integer index) {
+    this.index = index;
+  }
+
+  /**
+   * @param outputFolder the outputFolder to set
+   */
+  public void setOutputFolder(String outputFolder) {
+    this.outputFolder = outputFolder;
+  }
+
+private String outputFolder;
 
   /**
    * Instantiates a new transaction storage type.
index a317c29..4c37c08 100644 (file)
@@ -33,16 +33,30 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.onap.aai.sparky.analytics.AveragingRingBuffer;
-import org.powermock.modules.junit4.PowerMockRunner;
+import org.mockito.runners.MockitoJUnitRunner;
 
 /**
  * The Class AveragingRingBufferTest.
  */
-@RunWith(PowerMockRunner.class)
+@RunWith(MockitoJUnitRunner.class) 
 public class AveragingRingBufferTest {
 
   protected SecureRandom random = new SecureRandom();
 
+  /**
+   * @return the random
+   */
+  public SecureRandom getRandom() {
+    return random;
+  }
+
+  /**
+   * @param random the random to set
+   */
+  public void setRandom(SecureRandom random) {
+    this.random = random;
+  }
+
   /**
    * Inits the.
    *
index 7304096..60a67d5 100644 (file)
@@ -31,12 +31,12 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.onap.aai.sparky.analytics.HistogramSampler;
-import org.powermock.modules.junit4.PowerMockRunner;
+import org.mockito.runners.MockitoJUnitRunner;
 
 /**
  * The Class HistogramSamplerTest.
  */
-@RunWith(PowerMockRunner.class)
+@RunWith(MockitoJUnitRunner.class) 
 public class HistogramSamplerTest {
 
   protected SecureRandom random = new SecureRandom();
index 0c9967d..fe6fa56 100644 (file)
@@ -36,10 +36,7 @@ import static org.mockito.Mockito.mock;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.onap.aai.sparky.dal.rest.OperationResult;
-import org.onap.aai.sparky.dal.rest.RestClientBuilder;
-import org.onap.aai.sparky.dal.rest.RestfulDataAccessor;
-import org.powermock.modules.junit4.PowerMockRunner;
+import org.mockito.runners.MockitoJUnitRunner;
 
 import com.sun.jersey.api.client.Client;
 import com.sun.jersey.api.client.ClientResponse;
@@ -49,7 +46,7 @@ import com.sun.jersey.api.client.WebResource.Builder;
 /**
  * The Class RestfulDataAccessorTest.
  */
-@RunWith(PowerMockRunner.class)
+@RunWith(MockitoJUnitRunner.class) 
 public class RestfulDataAccessorTest {
 
   private RestClientBuilder clientBuilderMock;
index 2a8a945..d2cddcb 100644 (file)
@@ -31,13 +31,13 @@ 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;
-import org.powermock.modules.junit4.PowerMockRunner;
 
 /**
  * The Class GeoIndexDocumentTest.
  */
-@RunWith(PowerMockRunner.class)
+@RunWith(MockitoJUnitRunner.class) 
 public class GeoIndexDocumentTest {
 
   /**
index eeebac8..822e927 100644 (file)
@@ -32,9 +32,9 @@ 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.config.oxm.OxmModelLoader;
 import org.onap.aai.sparky.util.LogValidator;
-import org.powermock.modules.junit4.PowerMockRunner;
 
 import ch.qos.logback.classic.Level;
 
@@ -42,7 +42,7 @@ import ch.qos.logback.classic.Level;
 /**
  * The Class IndexDocumentTest.
  */
-@RunWith(PowerMockRunner.class)
+@RunWith(MockitoJUnitRunner.class) 
 public class IndexDocumentTest {
 
   private LogValidator logValidator;
index 55688d9..b4305cb 100644 (file)
@@ -1,28 +1,16 @@
 package org.onap.aai.sparky.synchronizer;
 
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
 
 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 {
diff --git a/src/test/java/org/onap/aai/sparky/synchronizer/entity/IndexableEntityTest.java b/src/test/java/org/onap/aai/sparky/synchronizer/entity/IndexableEntityTest.java
new file mode 100644 (file)
index 0000000..7da2d6e
--- /dev/null
@@ -0,0 +1,43 @@
+package org.onap.aai.sparky.synchronizer.entity;
+
+import org.junit.Test;
+
+import com.openpojo.reflection.PojoClass;
+import com.openpojo.reflection.impl.PojoClassFactory;
+import com.openpojo.validation.PojoValidator;
+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 IndexableEntityTest {
+// The package to be tested
+         private String packageName = "org.onap.aai.sparky.synchronizer.entity";
+
+         /**
+     * @return the packageName
+     */
+    public String getPackageName() {
+      return packageName;
+    }
+
+    /**
+     * @param packageName the packageName to set
+     */
+    public void setPackageName(String packageName) {
+      this.packageName = packageName;
+    }
+
+    @Test
+         public void validate() {
+           Validator validator = ValidatorBuilder.create()
+                                   .with(new SetterMustExistRule(),
+                                         new GetterMustExistRule())
+                                   .with(new SetterTester(),
+                                         new GetterTester())
+                                   .build();
+           validator.validate(packageName);
+         }
+}
index 0fff1fb..15d46dd 100644 (file)
@@ -32,13 +32,13 @@ import static org.junit.Assert.assertNull;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.mockito.runners.MockitoJUnitRunner;
 import org.onap.aai.sparky.viewandinspect.entity.QuerySearchEntity;
-import org.powermock.modules.junit4.PowerMockRunner;
 
 /**
  * The Class ViewAndInspectSearchRequestTest.
  */
-@RunWith(PowerMockRunner.class)
+@RunWith(MockitoJUnitRunner.class) 
 public class ViewAndInspectSearchRequestTest {
 
   /**
index 496ceb2..023855b 100644 (file)
@@ -34,13 +34,12 @@ import java.security.NoSuchAlgorithmException;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.onap.aai.sparky.viewandinspect.entity.EntityEntry;
-import org.powermock.modules.junit4.PowerMockRunner;
+import org.mockito.runners.MockitoJUnitRunner;
 
 /**
  * The Class EntityEntryTest.
  */
-@RunWith(PowerMockRunner.class)
+@RunWith(MockitoJUnitRunner.class) 
 public class EntityEntryTest {
 
   /**