summaryrefslogtreecommitdiffstats
path: root/vid-app-common
diff options
context:
space:
mode:
Diffstat (limited to 'vid-app-common')
-rwxr-xr-xvid-app-common/pom.xml69
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java71
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java10
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/PombaClientImpl.java5
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/CategoryParameterOption.java40
-rw-r--r--vid-app-common/src/test/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtilTest.java55
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/AAITreeConverterTest.java (renamed from vid-app-common/src/test/java/org/onap/vid/services/AAITreeConverterTest.java)19
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientServerTest.java17
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientTest.java12
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/AaiResponseTranslatorTest.java (renamed from vid-app-common/src/test/java/org/onap/vid/services/AaiResponseTranslatorTest.java)8
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/PombaClientImplTest.java4
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/PombaRestInterfaceTest.java127
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/util/HttpsAuthClientTest.java15
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/util/SingleAAIRestInterfaceTest.java16
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/model/CategoryParameterOptionTest.java186
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/model/CategoryParameterTest.java186
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java6
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/MsoResponseWrapper2Test.java83
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/MsoResponseWrapperTest.java27
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/RestObjectTest.java20
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentActivateInfoTest.java67
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentDeactivateInfoTest.java44
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/JobsBrokerServiceTest.java60
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java48
24 files changed, 633 insertions, 562 deletions
diff --git a/vid-app-common/pom.xml b/vid-app-common/pom.xml
index 22911c25a..6b73d79ca 100755
--- a/vid-app-common/pom.xml
+++ b/vid-app-common/pom.xml
@@ -337,6 +337,75 @@
</includeOnlyProperties>
</configuration>
</plugin>
+
+ <plugin>
+ <!--
+ Replace phase "none" with "process-sources" to enable.
+ Set organizationName as desired.
+ Then run `mvn license:check-file-header`, or even `mvn
+ license:update-file-header`.
+ -->
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>license-maven-plugin</artifactId>
+ <version>1.17</version>
+
+ <executions>
+ <execution>
+ <id>first</id>
+ <goals>
+ <goal>update-file-header</goal>
+ </goals>
+ <!-- replace phase "none" with "process-sources" to enable -->
+ <phase>none</phase>
+ </execution>
+ </executions>
+
+ <configuration>
+ <canUpdateCopyright>false</canUpdateCopyright>
+ <canUpdateDescription>false</canUpdateDescription>
+ <licenseName>apache_v2</licenseName>
+ <processStartTag>============LICENSE_START=======================================================</processStartTag>
+ <processEndTag>============LICENSE_END=========================================================</processEndTag>
+ <sectionDelimiter>================================================================================</sectionDelimiter>
+ <projectName>VID</projectName>
+ <inceptionYear>2017</inceptionYear>
+ <organizationName>AT&amp;T Intellectual Property. All rights reserved.</organizationName>
+ <canUpdateLicense>true</canUpdateLicense>
+ <addJavaLicenseAfterPackage>false</addJavaLicenseAfterPackage>
+ <emptyLineAfterHeader>true</emptyLineAfterHeader>
+ <verbose>false</verbose>
+
+ <includes>
+ <include>**/*.java</include>
+ <include>**/*.kt</include>
+ <include>**/*.jsp</include>
+ <include>**/*.xml</include>
+ <include>**/*.js</include>
+ <include>**/*.ts</include>
+ <include>**/*.html</include>
+ <include>**/*.css</include>
+ <include>**/*.sql</include>
+ </includes>
+
+ <extraExtensions>
+ <sql>mysql</sql>
+ </extraExtensions>
+
+ <roots>
+ <root>src/main</root>
+ <root>src/test</root>
+ </roots>
+
+ <excludes>
+ <exclude>**/app/vid/external/**/*</exclude>
+ <exclude>**/main/webapp/WEB-INF/**/*</exclude>
+ <exclude>**/test/resources/WEB-INF/**/*</exclude>
+ <exclude>**/app/vid/scripts/angular-ui-tree.js</exclude>
+ </excludes>
+
+ </configuration>
+ </plugin>
+
</plugins>
</build>
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
index 126fbe8d3..6a8439fee 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
@@ -20,8 +20,26 @@
package org.onap.vid.aai;
+import static java.util.Collections.emptyList;
+import static java.util.stream.Collectors.toMap;
+import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
+import static org.apache.commons.lang3.StringUtils.equalsIgnoreCase;
+import static org.apache.commons.lang3.StringUtils.isEmpty;
+
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URLEncoder;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.function.Function;
+import javax.inject.Inject;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpStatus;
import org.apache.http.client.utils.URIBuilder;
@@ -32,12 +50,28 @@ import org.json.simple.parser.JSONParser;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.vid.aai.exceptions.InvalidAAIResponseException;
import org.onap.vid.aai.model.AaiGetAicZone.AicZones;
-import org.onap.vid.aai.model.*;
-import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.*;
+import org.onap.vid.aai.model.AaiGetInstanceGroupsByCloudRegion;
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.AaiGetNetworkCollectionDetails;
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.AaiGetNetworkCollectionDetailsHelper;
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.AaiGetRelatedInstanceGroupsByVnfId;
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.CloudRegion;
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.InstanceGroup;
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Network;
import org.onap.vid.aai.model.AaiGetOperationalEnvironments.OperationalEnvironmentList;
+import org.onap.vid.aai.model.AaiGetPnfResponse;
import org.onap.vid.aai.model.AaiGetPnfs.Pnf;
import org.onap.vid.aai.model.AaiGetServicesRequestModel.GetServicesAAIRespone;
import org.onap.vid.aai.model.AaiGetTenatns.GetTenantsResponse;
+import org.onap.vid.aai.model.CustomQuerySimpleResult;
+import org.onap.vid.aai.model.GetServiceModelsByDistributionStatusResponse;
+import org.onap.vid.aai.model.LogicalLinkResponse;
+import org.onap.vid.aai.model.OwningEntityResponse;
+import org.onap.vid.aai.model.PortDetailsTranslator;
+import org.onap.vid.aai.model.ProjectResponse;
+import org.onap.vid.aai.model.Properties;
+import org.onap.vid.aai.model.ResourceType;
+import org.onap.vid.aai.model.ServiceRelationships;
+import org.onap.vid.aai.model.SimpleResult;
import org.onap.vid.aai.util.AAIRestInterface;
import org.onap.vid.aai.util.CacheProvider;
import org.onap.vid.aai.util.VidObjectMapperType;
@@ -51,23 +85,6 @@ import org.onap.vid.utils.Unchecked;
import org.springframework.http.HttpMethod;
import org.springframework.web.util.UriUtils;
-import javax.inject.Inject;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Response;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URLEncoder;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.function.Function;
-
-import static java.util.Collections.emptyList;
-import static java.util.stream.Collectors.toMap;
-import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
-
/**
* Created by Oren on 7/4/17.
@@ -233,7 +250,7 @@ public class AaiClient implements AaiClientInterface {
@Override
public boolean isNodeTypeExistsByName(String name, ResourceType type) {
- if (StringUtils.isEmpty(name)) {
+ if (isEmpty(name)) {
throw new GenericUncheckedException("Empty resource-name provided to searchNodeTypeByName; request is rejected as this will cause full resources listing");
}
@@ -697,7 +714,7 @@ public class AaiClient implements AaiClientInterface {
String propKey = checkForNull((String) innerObj.get("property-key"));
String propVal = checkForNull((String) innerObj.get("property-value"));
- if (propKey.equalsIgnoreCase("tenant.tenant-name")) {
+ if (equalsIgnoreCase(propKey, "tenant.tenant-name")) {
tenantNewObj.put("tenantName", propVal);
}
}
@@ -708,11 +725,11 @@ public class AaiClient implements AaiClientInterface {
String rShipKey = checkForNull((String) inner2Obj.get("relationship-key"));
String rShipVal = checkForNull((String) inner2Obj.get("relationship-value"));
- if (rShipKey.equalsIgnoreCase("cloud-region.cloud-owner")) {
+ if (equalsIgnoreCase(rShipKey, "cloud-region.cloud-owner")) {
tenantNewObj.put("cloudOwner", rShipVal);
- } else if (rShipKey.equalsIgnoreCase("cloud-region.cloud-region-id")) {
+ } else if (equalsIgnoreCase(rShipKey, "cloud-region.cloud-region-id")) {
tenantNewObj.put("cloudRegionID", rShipVal);
- } else if (rShipKey.equalsIgnoreCase("tenant.tenant-id")) {
+ } else if (equalsIgnoreCase(rShipKey, "tenant.tenant-id")) {
tenantNewObj.put("tenantID", rShipVal);
}
}
@@ -768,12 +785,12 @@ public class AaiClient implements AaiClientInterface {
@Override
public GetTenantsResponse getHomingDataByVfModule(String vnfInstanceId, String vfModuleId) {
- if (StringUtils.isEmpty(vnfInstanceId)||StringUtils.isEmpty(vfModuleId)){
+ if (isEmpty(vnfInstanceId)|| isEmpty(vfModuleId)){
throw new GenericUncheckedException("Failed to retrieve homing data associated to vfModule from A&AI, VNF InstanceId or VF Module Id is missing.");
}
Response resp = doAaiGet("network/generic-vnfs/generic-vnf/" + vnfInstanceId +"/vf-modules/vf-module/"+ vfModuleId, false);
String responseAsString = parseForTenantsByServiceSubscription("vserver",resp.readEntity(String.class));
- if (responseAsString.equals("")){
+ if (isEmpty(responseAsString)){
throw new GenericUncheckedException( String.format("A&AI has no homing data associated to vfModule '%s' of vnf '%s'", vfModuleId, vnfInstanceId));
}
else {
@@ -822,7 +839,7 @@ public class AaiClient implements AaiClientInterface {
Response resp = doAaiGet(url, false);
String responseAsString = parseForTenantsByServiceSubscription("tenant",resp.readEntity(String.class));
- if (StringUtils.isEmpty(responseAsString)){
+ if (isEmpty(responseAsString)){
throw new ParsingGetTenantsResponseFailure(String.format("A&AI has no LCP Region & Tenants associated to subscriber '%s' and service type '%s'", globalCustomerId, serviceType));
}
else {
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java
index fdbe418ea..43be049a6 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java
@@ -21,21 +21,19 @@
package org.onap.vid.aai;
import com.fasterxml.jackson.databind.JsonNode;
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+import javax.ws.rs.core.Response;
import org.onap.vid.aai.model.AaiGetOperationalEnvironments.OperationalEnvironmentList;
import org.onap.vid.aai.model.AaiGetPnfs.Pnf;
import org.onap.vid.aai.model.AaiGetTenatns.GetTenantsResponse;
-import org.onap.vid.aai.model.CustomQuerySimpleResult;
import org.onap.vid.aai.model.PortDetailsTranslator;
import org.onap.vid.aai.model.Properties;
import org.onap.vid.aai.model.ResourceType;
import org.onap.vid.model.SubscriberList;
import org.onap.vid.model.probes.ExternalComponentStatus;
-import javax.ws.rs.core.Response;
-import java.net.URI;
-import java.util.List;
-import java.util.Map;
-
/**
* Created by Oren on 7/4/17.
*/
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/PombaClientImpl.java b/vid-app-common/src/main/java/org/onap/vid/aai/PombaClientImpl.java
index e22040157..1ee4da0b4 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/PombaClientImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/PombaClientImpl.java
@@ -3,13 +3,14 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nokia. 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.
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameterOption.java b/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameterOption.java
index 237747933..70f7b5aa2 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameterOption.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameterOption.java
@@ -20,12 +20,19 @@
package org.onap.vid.model;
-import org.onap.portalsdk.core.domain.support.DomainVo;
-
-import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.Set;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import org.onap.portalsdk.core.domain.support.DomainVo;
@Entity
@Table(name = "vid_category_parameter_option")
@@ -124,24 +131,39 @@ public class CategoryParameterOption extends DomainVo {
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
CategoryParameterOption that = (CategoryParameterOption) o;
- if (getAppId() != null ? !getAppId().equals(that.getAppId()) : that.getAppId() != null) return false;
- if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null) return false;
- return getCategoryParameter() != null ? getCategoryParameter().equals(that.getCategoryParameter()) : that.getCategoryParameter() == null;
+ if (getAppId() != null ? !getAppId().equals(that.getAppId()) : that.getAppId() != null) {
+ return false;
+ }
+ if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null) {
+ return false;
+ }
+ return getCategoryParameter() != null ? getCategoryParameter().equals(that.getCategoryParameter())
+ : that.getCategoryParameter() == null;
}
@Override
public int hashCode() {
int result = getAppId() != null ? getAppId().hashCode() : 0;
result = 31 * result + (getName() != null ? getName().hashCode() : 0);
- result = 31 * result + (getCategoryParameter() != null ? getCategoryParameter().hashCode() : 0);
+ result = 31 * result + hashCodeOfParentCategoryParameter();
return result;
}
+ private int hashCodeOfParentCategoryParameter() {
+ // Don't use getCategoryParameter's hashCode, as it might loop back to self's hasCode
+ return (getCategoryParameter() == null || getCategoryParameter().getId() == null)
+ ? 0 : getCategoryParameter().getId().hashCode();
+ }
+
@Override
public String toString() {
return "CategoryParameterOption{" +
diff --git a/vid-app-common/src/test/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtilTest.java b/vid-app-common/src/test/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtilTest.java
index 98be994fa..e06805cc1 100644
--- a/vid-app-common/src/test/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtilTest.java
+++ b/vid-app-common/src/test/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtilTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,23 +20,52 @@
package org.onap.aai.util;
+import static org.mockito.ArgumentMatchers.contains;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import java.io.PrintStream;
+import java.util.Arrays;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
import org.onap.vid.aai.util.JettyObfuscationConversionCommandLineUtil;
+@RunWith(Parameterized.class)
public class JettyObfuscationConversionCommandLineUtilTest {
- private JettyObfuscationConversionCommandLineUtil createTestSubject() {
- return new JettyObfuscationConversionCommandLineUtil();
- }
+ final String[] args;
+ final String expected;
+
+ public JettyObfuscationConversionCommandLineUtilTest(String description, String[] args, String expected) {
+ this.args = args;
+ this.expected = expected;
+ }
-
- @Test
- public void testMain() throws Exception {
- String[] args = new String[] { "" };
+ @Parameters(name = "{0}")
+ public static Iterable<Object[]> data() {
+ return Arrays.asList(new Object[][]{
+ {"print usage on missing params", new String[]{}, "usage:"},
+ {"obfuscate", new String[]{"-e", "foobar"}, "OBF:1vub1ua51uh81ugi1u9d1vuz"},
+ {"deobfuscate", new String[]{"-d", "OBF:1vub1ua51uh81ugi1u9d1vuz"}, "foobar"},
+ {"input parse exception", new String[]{"mm", "-mm", "-mm"}, "failed to parse input"},
+ {"deobfuscate exception", new String[]{"-d", "problematic string"},
+ "exception:java.lang.NumberFormatException"},
+ });
+ }
- // default test
- JettyObfuscationConversionCommandLineUtil.main(args);
- }
+ @Test
+ public void testMain() {
+ final PrintStream originalOut = System.out;
+ try {
+ PrintStream mockedOut = mock(PrintStream.class);
+ System.setOut(mockedOut);
+ JettyObfuscationConversionCommandLineUtil.main(args);
+ verify(mockedOut).println(contains(expected));
+ } finally {
+ System.setOut(originalOut);
+ }
+ }
-
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AAITreeConverterTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/AAITreeConverterTest.java
index 5abe8e426..8bcadd139 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/AAITreeConverterTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/AAITreeConverterTest.java
@@ -3,13 +3,14 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nokia. 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.
@@ -18,14 +19,18 @@
* ============LICENSE_END=========================================================
*/
-package org.opencomp.vid.services;
+package org.onap.vid.aai;
import com.google.common.collect.ImmutableList;
import org.mockito.InjectMocks;
import org.mockito.MockitoAnnotations;
import org.onap.vid.aai.util.AAITreeConverter;
import org.onap.vid.model.Action;
-import org.onap.vid.model.aaiTree.*;
+import org.onap.vid.model.aaiTree.AAITreeNode;
+import org.onap.vid.model.aaiTree.Network;
+import org.onap.vid.model.aaiTree.ServiceInstance;
+import org.onap.vid.model.aaiTree.VfModule;
+import org.onap.vid.model.aaiTree.Vnf;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -33,7 +38,11 @@ import org.testng.annotations.Test;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.emptyOrNullString;
+import static org.hamcrest.Matchers.hasKey;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
import static org.onap.vid.asdc.parser.ToscaParserImpl2.Constants.A_LA_CARTE;
public class AAITreeConverterTest {
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientServerTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientServerTest.java
index fce9fa211..dd7b26c12 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientServerTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientServerTest.java
@@ -28,20 +28,20 @@ import org.assertj.core.api.Assertions;
import org.glassfish.grizzly.http.util.HttpStatus;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
import org.onap.vid.aai.model.ResourceType;
import org.onap.vid.client.SyncRestClient;
import org.onap.vid.model.SubscriberList;
import org.onap.vid.testUtils.StubServerUtil;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
import java.io.IOException;
-@RunWith(MockitoJUnitRunner.class)
+import static org.mockito.MockitoAnnotations.initMocks;
+
public class AaiOverTLSClientServerTest {
@Mock
@@ -100,6 +100,11 @@ public class AaiOverTLSClientServerTest {
serverUtil.stopServer();
}
+ @BeforeMethod
+ public void setUp(){
+ initMocks(this);
+ }
+
@Test
public void shouldSearchNodeTypeByName() throws IOException, ParseException {
ObjectMapper objectMapper = getFasterXmlObjectMapper();
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientTest.java
index 702a9e0a8..43fb5a3bb 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientTest.java
@@ -21,24 +21,23 @@
package org.onap.vid.aai;
import com.google.common.collect.ImmutableMap;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
+
import org.onap.vid.aai.model.ResourceType;
import org.onap.vid.client.SyncRestClient;
import org.onap.vid.model.SubscriberList;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
import java.util.Collections;
import java.util.Map;
import static org.mockito.ArgumentMatchers.contains;
import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.MockitoAnnotations.initMocks;
-@RunWith(MockitoJUnitRunner.class)
public class AaiOverTLSClientTest {
private static final String SEARCH_NODES_QUERY_SEARCH_NODE_TYPE = "nodes/generic-vnfs?vnf-name=name";
@@ -50,8 +49,9 @@ public class AaiOverTLSClientTest {
@Mock
private AaiOverTLSPropertySupplier propertySupplier;
- @Before
+ @BeforeMethod
public void setUp() {
+ initMocks(this);
aaiRestClient = new AaiOverTLSClient(syncRestClient, propertySupplier);
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AaiResponseTranslatorTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/AaiResponseTranslatorTest.java
index cc6f99fc6..12f7429eb 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/AaiResponseTranslatorTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/AaiResponseTranslatorTest.java
@@ -3,13 +3,14 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nokia. 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.
@@ -18,11 +19,10 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.vid.services;
+package org.onap.vid.aai;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
-import org.onap.vid.aai.AaiResponseTranslator;
import org.onap.vid.aai.AaiResponseTranslator.PortMirroringConfigData;
import org.onap.vid.aai.AaiResponseTranslator.PortMirroringConfigDataError;
import org.onap.vid.aai.AaiResponseTranslator.PortMirroringConfigDataOk;
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/PombaClientImplTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/PombaClientImplTest.java
index 483feec91..222bf1e5b 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/PombaClientImplTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/PombaClientImplTest.java
@@ -7,9 +7,9 @@
* 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.
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/PombaRestInterfaceTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/PombaRestInterfaceTest.java
new file mode 100644
index 000000000..b409c1f46
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/PombaRestInterfaceTest.java
@@ -0,0 +1,127 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2019 Nokia
+ * ================================================================================
+ * 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.onap.vid.aai;
+
+
+import org.mockito.Mock;
+import org.onap.vid.aai.util.HttpClientMode;
+import org.onap.vid.aai.util.HttpsAuthClient;
+import org.onap.vid.aai.util.ServletRequestHelper;
+import org.onap.vid.aai.util.SystemPropertyHelper;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import java.util.UUID;
+import java.util.regex.Pattern;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.matches;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.FROM_APP_ID_HEADER;
+import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.TRANSACTION_ID_HEADER;
+import static org.onap.vid.utils.Logging.REQUEST_ID_HEADER_KEY;
+
+public class PombaRestInterfaceTest {
+ private static final String UUID_REGEX = "[a-f0-9]{8}(-[a-f0-9]{4}){3}-[a-f0-9]{12}";
+ private static final String SAMPLE_APP_ID = "vid";
+ private static final String SAMPLE_URL = "sampleUrl";
+ private static final String SAMPLE_PAYLOAD = "samplePayload";
+ private static final Pattern UUID_PATTERN = Pattern.compile(UUID_REGEX);
+
+ @Mock
+ private HttpsAuthClient authClient;
+
+ @Mock
+ private ServletRequestHelper requestHelper;
+
+ @Mock
+ private SystemPropertyHelper systemPropertyHelper;
+
+ @Mock
+ private Client client;
+
+ @Mock
+ private WebTarget webTarget;
+
+ @Mock
+ private Invocation.Builder builder;
+
+ @Mock
+ private Response response;
+
+ private PombaRestInterface pombaRestInterface;
+
+ @BeforeMethod
+ public void setUp() throws GeneralSecurityException, IOException {
+ initMocks(this);
+
+ when(requestHelper.extractOrGenerateRequestId()).thenReturn(UUID.randomUUID().toString());
+ when(authClient.getClient(HttpClientMode.WITH_KEYSTORE)).thenReturn(client);
+ setUpBuilder();
+ pombaRestInterface = new PombaRestInterface(authClient, requestHelper, systemPropertyHelper);
+ }
+
+
+ @Test
+ public void shouldProperlySendRequestWithAllRequiredHeaders() {
+ Response actualResponse = pombaRestInterface.RestPost(SAMPLE_APP_ID, SAMPLE_URL, SAMPLE_PAYLOAD);
+
+ assertThat(actualResponse).isEqualTo(response);
+
+ verify(builder).accept(MediaType.APPLICATION_JSON);
+ verify(builder).header(FROM_APP_ID_HEADER, SAMPLE_APP_ID);
+ verify(builder).header(matches(TRANSACTION_ID_HEADER), matches(UUID_PATTERN));
+ verify(builder).header(matches(REQUEST_ID_HEADER_KEY), matches(UUID_PATTERN));
+ verify(builder).post(any(Entity.class));
+ }
+
+ @Test
+ public void shouldReturnNullWhenExceptionWasRaised() {
+ doThrow(new RuntimeException()).when(client).target(anyString());
+
+ Response actualResponse = pombaRestInterface.RestPost(SAMPLE_APP_ID, SAMPLE_URL, SAMPLE_PAYLOAD);
+
+ assertThat(actualResponse).isNull();
+ }
+
+ private void setUpBuilder() {
+ when(client.target(anyString())).thenReturn(webTarget);
+ when(webTarget.request()).thenReturn(builder);
+ when(builder.accept(MediaType.APPLICATION_JSON)).thenReturn(builder);
+ when(builder.header(anyString(), any())).thenReturn(builder);
+ when(builder.post(any(Entity.class))).thenReturn(response);
+ when(response.getStatusInfo()).thenReturn(Response.Status.OK);
+ }
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/util/HttpsAuthClientTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/util/HttpsAuthClientTest.java
index aff6c7f76..3336a8af9 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/util/HttpsAuthClientTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/util/HttpsAuthClientTest.java
@@ -21,13 +21,13 @@
package org.onap.vid.aai.util;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+
import org.onap.vid.aai.exceptions.HttpClientBuilderException;
import org.onap.vid.exceptions.GenericUncheckedException;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
import org.togglz.core.manager.FeatureManager;
import javax.net.ssl.SSLContext;
@@ -35,8 +35,8 @@ import java.util.Optional;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.*;
+import static org.mockito.MockitoAnnotations.initMocks;
-@RunWith(MockitoJUnitRunner.class)
public class HttpsAuthClientTest {
@Mock
private SystemPropertyHelper systemPropertyHelper;
@@ -51,14 +51,15 @@ public class HttpsAuthClientTest {
return new HttpsAuthClient(CERT_FILE_PATH, systemPropertyHelper, sslContextProvider, mock(FeatureManager.class));
}
- @Before
+ @BeforeMethod
public void setUp() throws Exception {
+ initMocks(this);
when(systemPropertyHelper.getAAITruststoreFilename()).thenReturn(Optional.of("filename"));
when(systemPropertyHelper.getDecryptedKeystorePassword()).thenReturn("password");
when(systemPropertyHelper.getDecryptedTruststorePassword()).thenReturn("password");
}
- @Test(expected = HttpClientBuilderException.class)
+ @Test(expectedExceptions = {HttpClientBuilderException.class})
public void testHttpClientBuilderExceptionOnGetClient() throws Exception {
//when
when(systemPropertyHelper.isClientCertEnabled()).thenReturn(true);
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/util/SingleAAIRestInterfaceTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/util/SingleAAIRestInterfaceTest.java
index 69e8ddcec..3393aa7c1 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/util/SingleAAIRestInterfaceTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/util/SingleAAIRestInterfaceTest.java
@@ -20,18 +20,18 @@
package org.onap.vid.aai.util;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
+
import org.onap.vid.aai.ExceptionWithRequestInfo;
import org.onap.vid.aai.exceptions.InvalidPropertyException;
import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.utils.Unchecked;
import org.springframework.http.HttpMethod;
import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.client.Client;
@@ -51,8 +51,9 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+
-@RunWith(MockitoJUnitRunner.class)
public class SingleAAIRestInterfaceTest {
private static final String PATH = "path";
@@ -78,8 +79,9 @@ public class SingleAAIRestInterfaceTest {
private AAIRestInterface testSubject;
- @Before
+ @BeforeMethod
public void setUp() throws Exception {
+ initMocks(this);
mockSystemProperties();
testSubject = createTestSubject();
when(client.target(HTTP_LOCALHOST+PATH)).thenReturn(webTarget);
@@ -130,7 +132,7 @@ public class SingleAAIRestInterfaceTest {
Assert.assertEquals(response, finalResponse);
}
- @Test(expected = ExceptionWithRequestInfo.class)
+ @Test(expectedExceptions = {ExceptionWithRequestInfo.class})
public void testFailedRestJsonPut() {
// given
String methodName = "RestPut";
diff --git a/vid-app-common/src/test/java/org/onap/vid/model/CategoryParameterOptionTest.java b/vid-app-common/src/test/java/org/onap/vid/model/CategoryParameterOptionTest.java
index 5fe392751..a3a14a2dd 100644
--- a/vid-app-common/src/test/java/org/onap/vid/model/CategoryParameterOptionTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/model/CategoryParameterOptionTest.java
@@ -20,190 +20,34 @@
package org.onap.vid.model;
-import java.io.Serializable;
-import java.util.Date;
-import java.util.Set;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanEqualsExcluding;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanHashCodeExcluding;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
-import org.junit.Assert;
+import org.apache.commons.lang3.ArrayUtils;
import org.junit.Test;
+import org.onap.portalsdk.core.domain.support.DomainVo;
+import org.onap.vid.testUtils.TestUtils;
public class CategoryParameterOptionTest {
- private CategoryParameterOption createTestSubject() {
- return new CategoryParameterOption();
- }
-
- @Test
- public void testGetId() throws Exception {
- CategoryParameterOption testSubject;
- Long result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getId();
- }
-
- @Test
- public void testSetId() throws Exception {
- CategoryParameterOption testSubject;
- Long id = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setId(id);
- }
-
- @Test
- public void testGetAppId() throws Exception {
- CategoryParameterOption testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAppId();
- }
-
- @Test
- public void testSetAppId() throws Exception {
- CategoryParameterOption testSubject;
- String appId = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setAppId(appId);
- }
-
- @Test
- public void testGetName() throws Exception {
- CategoryParameterOption testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getName();
- }
-
- @Test
- public void testSetName() throws Exception {
- CategoryParameterOption testSubject;
- String name = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setName(name);
- }
-
- @Test
- public void testGetCategoryParameter() throws Exception {
- CategoryParameterOption testSubject;
- CategoryParameter result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getCategoryParameter();
- }
-
- @Test
- public void testSetCategoryParameter() throws Exception {
- CategoryParameterOption testSubject;
- CategoryParameter categoryParameter = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setCategoryParameter(categoryParameter);
- }
-
- @Test
- public void testGetCreated() throws Exception {
- CategoryParameterOption testSubject;
- Date result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getCreated();
- }
-
- @Test
- public void testGetModified() throws Exception {
- CategoryParameterOption testSubject;
- Date result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getModified();
- }
-
- @Test
- public void testGetCreatedId() throws Exception {
- CategoryParameterOption testSubject;
- Long result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getCreatedId();
- }
+ final private String[] excludedProperties = TestUtils.allPropertiesOf(DomainVo.class);
@Test
- public void testGetModifiedId() throws Exception {
- CategoryParameterOption testSubject;
- Long result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getModifiedId();
- }
-
- @Test
- public void testGetAuditUserId() throws Exception {
- CategoryParameterOption testSubject;
- Serializable result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAuditUserId();
+ public void shouldHaveValidGettersAndSetters() {
+ assertThat(CategoryParameterOption.class, hasValidGettersAndSetters());
}
@Test
- public void testGetRowNum() throws Exception {
- CategoryParameterOption testSubject;
- Long result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getRowNum();
+ public void shouldHaveValidBeanHashCode() {
+ assertThat(CategoryParameterOption.class,
+ hasValidBeanHashCodeExcluding(ArrayUtils.addAll(new String[]{"categoryParameter"}, excludedProperties)));
}
@Test
- public void testGetAuditTrail() throws Exception {
- CategoryParameterOption testSubject;
- Set result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAuditTrail();
- }
-
- @Test
- public void testEquals() throws Exception {
- CategoryParameterOption testSubject;
- Object o = null;
- boolean result;
-
- // test 1
- testSubject = createTestSubject();
- o = null;
- result = testSubject.equals(o);
- Assert.assertEquals(false, result);
- }
-
- @Test
- public void testHashCode() throws Exception {
- CategoryParameterOption testSubject;
- int result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.hashCode();
+ public void shouldHaveValidBeanEquals() {
+ assertThat(CategoryParameterOption.class, hasValidBeanEqualsExcluding(excludedProperties));
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/model/CategoryParameterTest.java b/vid-app-common/src/test/java/org/onap/vid/model/CategoryParameterTest.java
index dc18c3065..c515a34d4 100644
--- a/vid-app-common/src/test/java/org/onap/vid/model/CategoryParameterTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/model/CategoryParameterTest.java
@@ -20,186 +20,64 @@
package org.onap.vid.model;
-import java.io.Serializable;
-import java.util.Date;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanEqualsExcluding;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanHashCodeExcluding;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.onap.vid.testUtils.TestUtils.allPropertiesOf;
+
+import com.google.common.collect.ImmutableSet;
import java.util.Set;
-
+import org.apache.commons.lang3.ArrayUtils;
import org.junit.Test;
+import org.onap.portalsdk.core.domain.support.DomainVo;
public class CategoryParameterTest {
- private CategoryParameter createTestSubject() {
- return new CategoryParameter();
- }
-
- @Test
- public void testGetFamily() throws Exception {
- CategoryParameter testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getFamily();
- }
-
- @Test
- public void testSetFamily() throws Exception {
- CategoryParameter testSubject;
- String family = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setFamily(family);
- }
-
- @Test
- public void testGetId() throws Exception {
- CategoryParameter testSubject;
- Long result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getId();
- }
-
- @Test
- public void testGetCreated() throws Exception {
- CategoryParameter testSubject;
- Date result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getCreated();
- }
-
- @Test
- public void testGetModified() throws Exception {
- CategoryParameter testSubject;
- Date result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getModified();
- }
-
- @Test
- public void testGetCreatedId() throws Exception {
- CategoryParameter testSubject;
- Long result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getCreatedId();
- }
-
- @Test
- public void testGetModifiedId() throws Exception {
- CategoryParameter testSubject;
- Long result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getModifiedId();
- }
-
- @Test
- public void testGetName() throws Exception {
- CategoryParameter testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getName();
- }
- @Test
- public void testSetName() throws Exception {
- CategoryParameter testSubject;
- String name = "";
+ final private String[] excludedProperties = allPropertiesOf(DomainVo.class);
- // default test
- testSubject = createTestSubject();
- testSubject.setName(name);
+ private ImmutableSet<CategoryParameterOption> optionsWithRefTo(CategoryParameter categoryParameter) {
+ return ImmutableSet.of(
+ new CategoryParameterOption("appId1", "name1", categoryParameter),
+ new CategoryParameterOption("appId2", "name2", categoryParameter)
+ );
}
@Test
- public void testGetAuditUserId() throws Exception {
- CategoryParameter testSubject;
- Serializable result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAuditUserId();
+ public void shouldHaveValidGettersAndSetters() {
+ assertThat(CategoryParameter.class, hasValidGettersAndSettersExcluding("options"));
}
@Test
- public void testGetRowNum() throws Exception {
- CategoryParameter testSubject;
- Long result;
+ public void testSetAndGetOptions() {
+ CategoryParameter testSubject = new CategoryParameter();
- // default test
- testSubject = createTestSubject();
- result = testSubject.getRowNum();
- }
-
- @Test
- public void testGetAuditTrail() throws Exception {
- CategoryParameter testSubject;
- Set result;
+ Set<CategoryParameterOption> options = optionsWithRefTo(testSubject);
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAuditTrail();
+ testSubject.setOptions(options);
+ assertThat(testSubject.getOptions(), containsInAnyOrder(optionsWithRefTo(testSubject).toArray()));
}
@Test
- public void testGetOptions() throws Exception {
- CategoryParameter testSubject;
- Set<CategoryParameterOption> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getOptions();
+ public void shouldHaveValidBeanHashCodeWithCycleReference() {
+ assertThat(CategoryParameter.class,
+ hasValidBeanHashCodeExcluding(ArrayUtils.addAll(new String[]{"options"}, excludedProperties)));
}
@Test
- public void testSetOptions() throws Exception {
- CategoryParameter testSubject;
- Set<CategoryParameterOption> options = null;
-
- // default test
- testSubject = createTestSubject();
+ public void hashCodeShouldNotExplodeWhenCycleReference() {
+ CategoryParameter testSubject = new CategoryParameter();
+ Set<CategoryParameterOption> options = optionsWithRefTo(testSubject);
testSubject.setOptions(options);
- }
- @Test
- public void testAddOption() throws Exception {
- CategoryParameter testSubject;
- CategoryParameterOption option = null;
- boolean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.addOption(option);
+ testSubject.hashCode(); // don't stackOverflow
}
@Test
- public void testIsIdSupported() throws Exception {
- CategoryParameter testSubject;
- boolean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.isIdSupported();
+ public void shouldHaveValidBeanEquals() {
+ assertThat(CategoryParameter.class, hasValidBeanEqualsExcluding(excludedProperties));
}
- @Test
- public void testSetIdSupported() throws Exception {
- CategoryParameter testSubject;
- boolean idSupported = false;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setIdSupported(idSupported);
- }
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java
index a5fb1a5f0..39d777be9 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java
@@ -3,14 +3,14 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2018 - 2019 Nokia. All rights reserved.
+ * Modifications Copyright (C) 2019 Nokia. 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.
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/MsoResponseWrapper2Test.java b/vid-app-common/src/test/java/org/onap/vid/mso/MsoResponseWrapper2Test.java
index 5ec645a90..dd959a8aa 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/MsoResponseWrapper2Test.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/MsoResponseWrapper2Test.java
@@ -3,13 +3,14 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nokia. 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.
@@ -20,41 +21,75 @@
package org.onap.vid.mso;
-import org.junit.Test;
+import static org.mockito.Mockito.when;
+
+import io.joshworks.restclient.http.HttpResponse;
+import org.mockito.Mock;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.MockitoAnnotations.initMocks;
public class MsoResponseWrapper2Test {
- private MsoResponseWrapper2 createTestSubject() {
- return new MsoResponseWrapper2(new RestObject());
+ @Mock
+ private RestObject<String> msoResponse;
+
+ @Mock
+ private HttpResponse<String> httpResponse;
+
+ private MsoResponseWrapper2<String> responseWrapper;
+
+ private int status = 202;
+ private String entity = "testEntity";
+ private String rawString = "testRawString";
+
+ @BeforeClass
+ public void setUp() {
+ initMocks(this);
}
@Test
- public void testGetStatus() throws Exception {
- MsoResponseWrapper2 testSubject;
- int result;
+ public void shouldProperlyCreateInstanceFromRestObject() {
+ // given
+ when(msoResponse.getStatusCode()).thenReturn(status);
+ when(msoResponse.get()).thenReturn(entity);
+ when(msoResponse.getRaw()).thenReturn(rawString);
+
+ // when
+ responseWrapper = new MsoResponseWrapper2<>(msoResponse);
- // default test
- testSubject = createTestSubject();
- result = testSubject.getStatus();
+ // then
+ assertThat(responseWrapper.getStatus()).isEqualTo(status);
+ assertThat(responseWrapper.getEntity()).isEqualTo(entity);
+ assertThat(responseWrapper.getResponse()).isEqualTo("{\"status\":"+status+",\"entity\":\""+entity+"\"}");
}
@Test
- public void testGetResponse() throws Exception {
- MsoResponseWrapper2 testSubject;
- String result;
+ public void shouldProperlyCreateInstanceFromHttpResponse() {
+ // given
+ when(httpResponse.getStatus()).thenReturn(status);
+ when(httpResponse.getBody()).thenReturn(entity);
- // default test
- testSubject = createTestSubject();
- result = testSubject.getResponse();
+ // when
+ responseWrapper = new MsoResponseWrapper2<>(httpResponse);
+
+ // then
+ assertThat(responseWrapper.getStatus()).isEqualTo(status);
+ assertThat(responseWrapper.getEntity()).isEqualTo(entity);
+ assertThat(responseWrapper.getResponse()).isEqualTo("{\"status\":"+status+",\"entity\":\""+entity+"\"}");
}
@Test
- public void testGetEntity() throws Exception {
- MsoResponseWrapper2 testSubject;
- Object result;
+ public void shouldProperlyCreateInstanceFromStatusAndEntity() {
+ // when
+ responseWrapper = new MsoResponseWrapper2<>(status,entity);
- // default test
- testSubject = createTestSubject();
- result = testSubject.getEntity();
+ // then
+ assertThat(responseWrapper.getStatus()).isEqualTo(status);
+ assertThat(responseWrapper.getEntity()).isEqualTo(entity);
+ assertThat(responseWrapper.getResponse()).isEqualTo("{\"status\":"+status+",\"entity\":\""+entity+"\"}");
}
-}
+
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/MsoResponseWrapperTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/MsoResponseWrapperTest.java
index 6cba339d1..191b91ba2 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/MsoResponseWrapperTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/MsoResponseWrapperTest.java
@@ -25,12 +25,12 @@ import org.mockito.Mock;
import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
-import org.testng.annotations.BeforeSuite;
-import org.testng.annotations.Test;
-import static org.assertj.core.api.Assertions.assertThat;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
import javax.ws.rs.core.Response;
@@ -46,7 +46,7 @@ public class MsoResponseWrapperTest {
private MsoResponseWrapper responseWrapper;
- @BeforeSuite
+ @BeforeClass
public void setUp() {
initMocks(this);
}
@@ -57,45 +57,58 @@ public class MsoResponseWrapperTest {
}
@Test
- public void shouldProperlyConstructResponseWrapperWithParameters(){
+ public void shouldProperlyConstructMsoResponseWrapperWithParameters(){
+ // when
responseWrapper = new MsoResponseWrapper(1,"testEntity");
+ // then
assertThat(responseWrapper.getStatus()).isEqualTo(1);
assertThat(responseWrapper.getEntity()).isEqualTo("testEntity");
}
@Test
- public void shouldProperlyConstructResponseWrapperFromResponse(){
+ public void shouldProperlyConstructMsoResponseWrapperFromResponse(){
+ // given
when(response.getStatus()).thenReturn(1);
when(response.readEntity(String.class)).thenReturn("testEntity");
+ // when
responseWrapper = new MsoResponseWrapper(response);
+ // then
assertThat(responseWrapper.getStatus()).isEqualTo(1);
assertThat(responseWrapper.getEntity()).isEqualTo("testEntity");
}
@Test
public void shouldProperlyGetResponseWithEmptyEntity(){
+ // given
responseWrapper = new MsoResponseWrapper();
+
+ // when
responseWrapper.setStatus(1);
+ // then
assertThat(responseWrapper.getResponse()).isEqualToIgnoringWhitespace(PROPER_RESPONSE_WITH_NO_ENTITY);
}
@Test
public void shouldProperlyGetResponse(){
+ // when
responseWrapper = new MsoResponseWrapper(1,"testEntity");
+ // then
assertThat(responseWrapper.getResponse()).isEqualToIgnoringWhitespace(PROPER_RESPONSE);
}
@Test
public void shouldProperlyConvertToString(){
+ // when
responseWrapper = new MsoResponseWrapper(1,"testEntity");
+ // then
assertThat(responseWrapper.toString()).endsWith(PROPER_TO_STRING);
}
-}
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/RestObjectTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/RestObjectTest.java
index 803083321..9f8614b92 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/RestObjectTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/RestObjectTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -21,7 +21,7 @@
package org.onap.vid.mso;
import org.hamcrest.MatcherAssert;
-import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
@@ -29,11 +29,11 @@ import static org.assertj.core.api.Assertions.assertThat;
public class RestObjectTest {
- private RestObject restObject;
+ private RestObject<Object> restObject;
- @BeforeSuite
+ @BeforeClass
private void setUp() {
- restObject = new RestObject();
+ restObject = new RestObject<>();
}
@Test
@@ -42,7 +42,7 @@ public class RestObjectTest {
}
@Test
- public void shouldHaveValidGetterAndSetterForBody() {
+ public void shouldHaveValidGetterAndSetterForTObject() {
// given
String testString = "set/get_testString";
@@ -54,13 +54,13 @@ public class RestObjectTest {
}
@Test
- public void shouldProperlyCopyRestObject() {
+ public void shouldProperlyCopyFromOneRestObjectToAnotherWithProperParameters() {
// given
MsoResponseWrapper testResponseWraper = new MsoResponseWrapper();
String rawTestString = "rawTestString";
int statusCode = 404;
- RestObject restObjectToCopyFrom = new RestObject<>();
+ RestObject<Object> restObjectToCopyFrom = new RestObject<>();
restObjectToCopyFrom.set(testResponseWraper);
restObjectToCopyFrom.setRaw(rawTestString);
restObjectToCopyFrom.setStatusCode(statusCode);
@@ -91,4 +91,4 @@ public class RestObjectTest {
// then
assertThat(toStringResponse).isEqualTo(properString);
}
-}
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentActivateInfoTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentActivateInfoTest.java
index 2a69e0e79..131e5dd46 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentActivateInfoTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentActivateInfoTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,45 +20,48 @@
package org.onap.vid.mso.model;
-import org.junit.Test;
import org.onap.vid.controller.OperationalEnvironmentController;
-import org.onap.vid.controller.OperationalEnvironmentController.OperationalEnvironmentActivateBody;
import org.onap.vid.controller.OperationalEnvironmentController.OperationalEnvironmentManifest;
+import org.testng.annotations.Test;
-public class OperationalEnvironmentActivateInfoTest {
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
- private OperationalEnvironmentActivateInfo createTestSubject() {
- OperationalEnvironmentController.OperationalEnvironmentActivateBody a = new OperationalEnvironmentActivateBody("a", "b", "c", new OperationalEnvironmentManifest());
- return new OperationalEnvironmentActivateInfo(a, "", "");
- }
+public class OperationalEnvironmentActivateInfoTest {
@Test
- public void testGetUserId() throws Exception {
- OperationalEnvironmentActivateInfo testSubject;
- String result;
+ public void shouldProperlyCreateOperationalEnvironmentActivateInfoWithParameters() {
+ // given
+ String relatedInstanceId = "testRelatedInstanceId";
+ String relatedInstanceName = "testRelatedInstanceName";
+ String workloadContext = "testWorkloadContext";
+ OperationalEnvironmentManifest manifest = new OperationalEnvironmentManifest();
- // default test
- testSubject = createTestSubject();
- result = testSubject.getUserId();
- }
+ String userId = "testUserId";
+ String operationalEnvironmentId = "testOperationalEnvironmentId";
- @Test
- public void testGetOperationalEnvironmentId() throws Exception {
- OperationalEnvironmentActivateInfo testSubject;
- String result;
+ OperationalEnvironmentController.OperationalEnvironmentActivateBody operationalEnvironmentActivateBody =
+ new OperationalEnvironmentController.OperationalEnvironmentActivateBody
+ (relatedInstanceId,relatedInstanceName,workloadContext,manifest);
- // default test
- testSubject = createTestSubject();
- result = testSubject.getOperationalEnvironmentId();
- }
+ // when
+ OperationalEnvironmentActivateInfo operationalEnvironmentActivateInfo =
+ new OperationalEnvironmentActivateInfo(operationalEnvironmentActivateBody, userId, operationalEnvironmentId);
- @Test
- public void testToString() throws Exception {
- OperationalEnvironmentActivateInfo testSubject;
- String result;
- // default test
- testSubject = createTestSubject();
- result = testSubject.toString();
+ // then
+ assertThat(operationalEnvironmentActivateInfo.getUserId()).isEqualTo(userId);
+ assertThat(operationalEnvironmentActivateInfo.getOperationalEnvironmentId()).isEqualTo(operationalEnvironmentId);
+
+ assertThat(operationalEnvironmentActivateInfo.toString()).isEqualToIgnoringWhitespace(
+ "OperationalEnvironmentActivateInfo{operationalEnvironmentId="+operationalEnvironmentId+"," +
+ " userId="+userId+"," +
+ " super=OperationalEnvironmentActivateInfo{" +
+ " relatedInstanceId="+relatedInstanceId+"," +
+ " relatedInstanceName="+relatedInstanceName+"," +
+ " workloadContext="+workloadContext+"," +
+ " manifest="+manifest.toString()+"}}"
+ );
+
}
-}
+
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentDeactivateInfoTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentDeactivateInfoTest.java
index 22310d2e2..72fb9d6dc 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentDeactivateInfoTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentDeactivateInfoTest.java
@@ -20,41 +20,31 @@
package org.onap.vid.mso.model;
-import org.junit.Test;
+import org.testng.annotations.Test;
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
public class OperationalEnvironmentDeactivateInfoTest {
- private OperationalEnvironmentDeactivateInfo createTestSubject() {
- return new OperationalEnvironmentDeactivateInfo("", "");
- }
-
@Test
- public void testGetUserId() throws Exception {
- OperationalEnvironmentDeactivateInfo testSubject;
- String result;
+ public void shouldProperlyCreateOperationalEnvironmentActivateInfoWithParameters() {
+ // given
+ String userId = "testUserId";
+ String operationalEnvironmentId = "testOperationalEnvironmentId";
- // default test
- testSubject = createTestSubject();
- result = testSubject.getUserId();
- }
- @Test
- public void testGetOperationalEnvironmentId() throws Exception {
- OperationalEnvironmentDeactivateInfo testSubject;
- String result;
+ // when
+ OperationalEnvironmentDeactivateInfo operationalEnvironmentDeactivateInfo =
+ new OperationalEnvironmentDeactivateInfo(userId, operationalEnvironmentId);
- // default test
- testSubject = createTestSubject();
- result = testSubject.getOperationalEnvironmentId();
- }
- @Test
- public void testToString() throws Exception {
- OperationalEnvironmentDeactivateInfo testSubject;
- String result;
+ // then
+ assertThat(operationalEnvironmentDeactivateInfo.getUserId()).isEqualTo(userId);
+ assertThat(operationalEnvironmentDeactivateInfo.getOperationalEnvironmentId()).isEqualTo(operationalEnvironmentId);
+
+ assertThat(operationalEnvironmentDeactivateInfo.toString()).isEqualToIgnoringWhitespace(
+ "OperationalEnvironmentDeactivateInfo{operationalEnvironmentId="+operationalEnvironmentId+"," +
+ " userId="+userId+"}"
+ );
- // default test
- testSubject = createTestSubject();
- result = testSubject.toString();
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/JobsBrokerServiceTest.java b/vid-app-common/src/test/java/org/onap/vid/services/JobsBrokerServiceTest.java
index 7b51225f3..85cf23edd 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/JobsBrokerServiceTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/JobsBrokerServiceTest.java
@@ -21,8 +21,45 @@
package org.onap.vid.services;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.stream.Collectors.toList;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.both;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.onap.vid.job.Job.JobStatus.COMPLETED;
+import static org.onap.vid.job.Job.JobStatus.CREATING;
+import static org.onap.vid.job.Job.JobStatus.FAILED;
+import static org.onap.vid.job.Job.JobStatus.IN_PROGRESS;
+import static org.onap.vid.job.Job.JobStatus.PAUSE;
+import static org.onap.vid.job.Job.JobStatus.PENDING;
+import static org.onap.vid.job.Job.JobStatus.RESOURCE_IN_PROGRESS;
+import static org.onap.vid.job.Job.JobStatus.STOPPED;
+import static org.onap.vid.utils.Streams.not;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.AssertJUnit.assertEquals;
+
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
+import java.lang.reflect.Method;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentSkipListSet;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeoutException;
+import java.util.stream.IntStream;
+import java.util.stream.Stream;
+import javax.inject.Inject;
import org.apache.commons.lang.RandomStringUtils;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
@@ -53,27 +90,6 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import javax.inject.Inject;
-import java.lang.reflect.Method;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.stream.IntStream;
-import java.util.stream.Stream;
-
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static java.util.stream.Collectors.toList;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.both;
-import static org.hamcrest.Matchers.containsInAnyOrder;
-import static org.onap.vid.job.Job.JobStatus.*;
-import static org.onap.vid.utils.Streams.not;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.AssertJUnit.assertEquals;
-
@ContextConfiguration(classes = {DataSourceConfig.class, SystemProperties.class, JobAdapterConfig.class})
public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests {
@@ -85,7 +101,7 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests {
private final Set<Long> threadsIds = new ConcurrentSkipListSet<>();
- private final long FEW = 500;
+ private final long FEW = 1000;
private final String JOBS_SHOULD_MATCH = "the jobs that added and those that pulled must be the same";
private final String JOBS_PEEKED_SHOULD_MATCH = "the jobs that added and those that peeked must be the same";
diff --git a/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java b/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java
index e2effd5ca..3a7d4690d 100644
--- a/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java
+++ b/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java
@@ -20,9 +20,32 @@
package org.onap.vid.testUtils;
+import static org.apache.commons.beanutils.PropertyUtils.getPropertyDescriptors;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.RETURNS_DEFAULTS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.withSettings;
+import static org.testng.Assert.fail;
+
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
+import java.beans.PropertyDescriptor;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.json.JSONArray;
@@ -32,28 +55,11 @@ import org.mockito.MockSettings;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
+import org.onap.portalsdk.core.domain.support.DomainVo;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.asdc.beans.Service;
import org.springframework.mock.env.MockEnvironment;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.GenericType;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Serializable;
-import java.net.URI;
-import java.util.Iterator;
-import java.util.List;
-
-import static fj.parser.Parser.fail;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.*;
-
/**
* Created by Oren on 6/7/17.
*/
@@ -125,6 +131,12 @@ public class TestUtils {
valueType);
}
+ public static String[] allPropertiesOf(Class<DomainVo> aClass) {
+ return Arrays.stream(getPropertyDescriptors(aClass))
+ .map(PropertyDescriptor::getDisplayName)
+ .toArray(String[]::new);
+ }
+
public static class JavaxRsClientMocks {
private final javax.ws.rs.client.Client fakeClient;