diff options
Diffstat (limited to 'mso-api-handlers')
23 files changed, 1316 insertions, 285 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/pom.xml b/mso-api-handlers/mso-api-handler-infra/pom.xml index 93b6c8fbb5..97bd8348d3 100644 --- a/mso-api-handlers/mso-api-handler-infra/pom.xml +++ b/mso-api-handlers/mso-api-handler-infra/pom.xml @@ -225,6 +225,18 @@ <artifactId>json</artifactId> <version>20160212</version> </dependency> + <dependency> + <groupId>org.jmockit</groupId> + <artifactId>jmockit</artifactId> + <version>1.19</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.12</version> + <scope>test</scope> + </dependency> <dependency> <groupId>pl.pragmatists</groupId> <artifactId>JUnitParams</artifactId> diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Action.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Action.java index 8c99d067e9..5c84e699d8 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Action.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Action.java @@ -37,5 +37,6 @@ public enum Action { removeRelationships, inPlaceSoftwareUpdate, applyUpdatedConfig, - compareModel + compareModel, + scaleInstance } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java index 2e0b53d5d8..5f74cb9ddd 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java @@ -56,6 +56,7 @@ import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.E2EServiceInsta import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.E2EServiceInstanceRequest;
import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.E2EUserParam;
import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.GetE2EServiceInstanceResponse;
+import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.*;
import org.openecomp.mso.serviceinstancebeans.ModelInfo;
import org.openecomp.mso.serviceinstancebeans.ModelType;
import org.openecomp.mso.serviceinstancebeans.RequestDetails;
@@ -160,6 +161,23 @@ public class E2EServiceInstances { return getE2EServiceInstances(serviceId, operationId);
}
+ /**
+ * Scale Requests for E2E Service scale Instance on a specified version
+ */
+
+ @POST
+ @Path("/{version:[vV][3-5]}/{serviceId}/scale")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Scale E2E Service Instance on a specified version",response=Response.class)
+ public Response scaleE2EServiceInstance(String request,
+ @PathParam("version") String version,
+ @PathParam("serviceId") String serviceId) {
+
+ msoLogger.debug("------------------scale begin------------------");
+ instanceIdMap.put("serviceId", serviceId);
+ return scaleE2EserviceInstances(request, Action.scaleInstance, instanceIdMap, version);
+ }
/**
* GET Requests for Comparing model of service instance with target version
*/
@@ -687,7 +705,7 @@ public class E2EServiceInstances { return response;
}
- if (curStatus != null && !curStatus.getProgress().equals("100")) {
+ if (curStatus != null && curStatus.getResult() != null && curStatus.getResult().equalsIgnoreCase("processing")) {
String chkMessage = "Error: Locked instance - This " + requestScope + " (" + requestId + ") "
+ "now being worked with a status of " + curStatus.getProgress() + " (ServiceName - "
+ curStatus.getServiceName()
@@ -921,6 +939,174 @@ public class E2EServiceInstances { return beplStatusUpdate(requestId, startTime, msoRequest, requestClient, respHandler, bpelStatus, action, instanceIdMap);
}
+ private Response scaleE2EserviceInstances(String requestJSON,
+ Action action, HashMap<String, String> instanceIdMap, String version) {
+
+ String requestId = instanceIdMap.get("serviceId");
+ long startTime = System.currentTimeMillis();
+ msoLogger.debug("requestId is: " + requestId);
+ E2EServiceInstanceScaleRequest e2eScaleReq = null;
+
+ MsoRequest msoRequest = new MsoRequest(requestId);
+
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ e2eScaleReq = mapper.readValue(requestJSON,
+ E2EServiceInstanceScaleRequest.class);
+
+ } catch (Exception e) {
+
+ msoLogger.debug("Mapping of request to JSON object failed : ", e);
+ Response response = msoRequest.buildServiceErrorResponse(
+ HttpStatus.SC_BAD_REQUEST,
+ MsoException.ServiceException,
+ "Mapping of request to JSON object failed. "
+ + e.getMessage(), ErrorNumbers.SVC_BAD_PARAMETER,
+ null);
+ msoLogger.error(MessageEnum.APIH_REQUEST_VALIDATION_ERROR,
+ MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.SchemaError, requestJSON, e);
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.SchemaError,
+ "Mapping of request to JSON object failed");
+ msoLogger.debug("End of the transaction, the final response is: "
+ + (String) response.getEntity());
+ createOperationStatusRecordForError(action, requestId);
+ return response;
+ }
+
+ CatalogDatabase db = null;
+ RecipeLookupResult recipeLookupResult = null;
+ try {
+ db = CatalogDatabase.getInstance();
+ //TODO Get the service template model version uuid from AAI.
+ recipeLookupResult = getServiceInstanceOrchestrationURI(db, null, action);
+ } catch (Exception e) {
+ msoLogger.error(MessageEnum.APIH_DB_ACCESS_EXC,
+ MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.AvailabilityError,
+ "Exception while communciate with Catalog DB", e);
+ msoRequest
+ .setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response response = msoRequest.buildServiceErrorResponse(
+ HttpStatus.SC_NOT_FOUND, MsoException.ServiceException,
+ "No communication to catalog DB " + e.getMessage(),
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ alarmLogger.sendAlarm("MsoDatabaseAccessError",
+ MsoAlarmLogger.CRITICAL, Messages.errors
+ .get(ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB));
+ msoRequest.createRequestRecord(Status.FAILED, action);
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.DBAccessError,
+ "Exception while communciate with DB");
+ msoLogger.debug(END_OF_THE_TRANSACTION
+ + (String) response.getEntity());
+ return response;
+ } finally {
+ closeCatalogDB(db);
+ }
+ if (recipeLookupResult == null) {
+ msoLogger.error(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND,
+ MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.DataError, "No recipe found in DB");
+ msoRequest
+ .setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response response = msoRequest.buildServiceErrorResponse(
+ HttpStatus.SC_NOT_FOUND, MsoException.ServiceException,
+ "Recipe does not exist in catalog DB",
+ ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null);
+ msoRequest.createRequestRecord(Status.FAILED, action);
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.DataNotFound,
+ "No recipe found in DB");
+ msoLogger.debug(END_OF_THE_TRANSACTION
+ + (String) response.getEntity());
+ createOperationStatusRecordForError(action, requestId);
+ return response;
+ }
+
+ RequestClient requestClient = null;
+ HttpResponse response = null;
+
+ long subStartTime = System.currentTimeMillis();
+ // String sirRequestJson = mapReqJsonToSvcInstReq(e2eSir, requestJSON);
+
+ try {
+ requestClient = RequestClientFactory.getRequestClient(
+ recipeLookupResult.getOrchestrationURI(),
+ MsoPropertiesUtils.loadMsoProperties());
+
+ JSONObject jjo = new JSONObject(requestJSON);
+ jjo.put("operationId", UUIDChecker.generateUUID(msoLogger));
+
+ String bpmnRequest = jjo.toString();
+
+ // Capture audit event
+ msoLogger
+ .debug("MSO API Handler Posting call to BPEL engine for url: "
+ + requestClient.getUrl());
+ String serviceId = instanceIdMap.get("serviceId");
+ String serviceInstanceType = e2eScaleReq.getService().getServiceType();
+ response = requestClient.post(requestId, false,
+ recipeLookupResult.getRecipeTimeout(), action.name(),
+ serviceId, null, null, null, null, null, serviceInstanceType,
+ null, null, null, bpmnRequest, recipeLookupResult.getRecipeParamXsd());
+
+ msoLogger.recordMetricEvent(subStartTime,
+ MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ "Successfully received response from BPMN engine", "BPMN",
+ recipeLookupResult.getOrchestrationURI(), null);
+ } catch (Exception e) {
+ msoLogger.recordMetricEvent(subStartTime,
+ MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError,
+ "Exception while communicate with BPMN engine", "BPMN",
+ recipeLookupResult.getOrchestrationURI(), null);
+ Response resp = msoRequest.buildServiceErrorResponse(
+ HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException,
+ "Failed calling bpmn " + e.getMessage(),
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ alarmLogger.sendAlarm("MsoConfigurationError",
+ MsoAlarmLogger.CRITICAL,
+ Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_BPEL));
+ msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR,
+ MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.AvailabilityError,
+ "Exception while communicate with BPMN engine");
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError,
+ "Exception while communicate with BPMN engine");
+ msoLogger.debug("End of the transaction, the final response is: "
+ + (String) resp.getEntity());
+ createOperationStatusRecordForError(action, requestId);
+ return resp;
+ }
+
+ if (response == null) {
+ Response resp = msoRequest.buildServiceErrorResponse(
+ HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException,
+ "bpelResponse is null",
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR,
+ MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.BusinessProcesssError,
+ "Null response from BPEL");
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.InternalError,
+ "Null response from BPMN");
+ msoLogger.debug(END_OF_THE_TRANSACTION + (String) resp.getEntity());
+ createOperationStatusRecordForError(action, requestId);
+ return resp;
+ }
+
+ ResponseHandler respHandler = new ResponseHandler(response,
+ requestClient.getType());
+ int bpelStatus = respHandler.getStatus();
+
+ return beplStatusUpdate(requestId, startTime, msoRequest,
+ requestClient, respHandler, bpelStatus, action, instanceIdMap);
+ }
+
private void closeCatalogDB(CatalogDatabase db) {
if (db != null) {
db.close();
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceScaleRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceScaleRequest.java new file mode 100644 index 0000000000..b8bd810f4f --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceScaleRequest.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 CMCC Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans; + + +public class E2EServiceInstanceScaleRequest { + + private ScaleService service; + + public ScaleService getService() { + return service; + } + + public void setService(ScaleService service) { + this.service = service; + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/ScaleNsByStepsData.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/ScaleNsByStepsData.java new file mode 100644 index 0000000000..c64f5fa207 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/ScaleNsByStepsData.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 CMCC Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans; + +public class ScaleNsByStepsData { + + private String aspectId; + + private Integer numberOfSteps; + + private String scalingDirection; + + public String getAspectId() { + return aspectId; + } + + public void setAspectId(String aspectId) { + this.aspectId = aspectId; + } + + public Integer getNumberOfSteps() { + return numberOfSteps; + } + + public void setNumberOfSteps(Integer numberOfSteps) { + this.numberOfSteps = numberOfSteps; + } + + public String getScalingDirection() { + return scalingDirection; + } + + public void setScalingDirection(String scalingDirection) { + this.scalingDirection = scalingDirection; + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/ScaleNsData.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/ScaleNsData.java new file mode 100644 index 0000000000..49cfe75a5b --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/ScaleNsData.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 CMCC Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans; + +public class ScaleNsData { + + private ScaleNsByStepsData scaleNsByStepsData; + + public ScaleNsByStepsData getScaleNsByStepsData() { + return scaleNsByStepsData; + } + + public void setScaleNsByStepsData(ScaleNsByStepsData scaleNsByStepsData) { + this.scaleNsByStepsData = scaleNsByStepsData; + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/ScaleResource.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/ScaleResource.java new file mode 100644 index 0000000000..f19e2bdb80 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/ScaleResource.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 CMCC Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans; + +public class ScaleResource { + + private String resourceInstanceId; + + private String scaleType; + + private ScaleNsData scaleNsData; + + public String getResourceInstanceId() { + return resourceInstanceId; + } + + public void setResourceInstanceId(String resourceInstanceId) { + this.resourceInstanceId = resourceInstanceId; + } + + public String getScaleType() { + return scaleType; + } + + public void setScaleType(String scaleType) { + this.scaleType = scaleType; + } + + public ScaleNsData getScaleNsData() { + return scaleNsData; + } + + public void setScaleNsData(ScaleNsData scaleNsData) { + this.scaleNsData = scaleNsData; + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/ScaleService.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/ScaleService.java new file mode 100644 index 0000000000..c694f550f8 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/ScaleService.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 CMCC Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans; + +import java.util.List; + +public class ScaleService { + + private String serviceInstanceName; + + private String serviceType; + + private String globalSubscriberId; + + private List<ScaleResource> resources; + + public String getServiceInstanceName() { + return serviceInstanceName; + } + + public void setServiceInstanceName(String serviceInstanceName) { + this.serviceInstanceName = serviceInstanceName; + } + + public String getServiceType() { + return serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + public String getGlobalSubscriberId() { + return globalSubscriberId; + } + + public void setGlobalSubscriberId(String globalSubscriberId) { + this.globalSubscriberId = globalSubscriberId; + } + + public List<ScaleResource> getResources() { + return resources; + } + + public void setResources(List<ScaleResource> resources) { + this.resources = resources; + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java index 590ac7cbed..c0f6ccc730 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java @@ -719,6 +719,7 @@ public class E2EServiceInstancesTest { String serviceID) {
OperationStatus operationStatus = new OperationStatus();
operationStatus.setProgress("100");
+ operationStatus.setResult("finish");
return operationStatus;
}
};
@@ -790,6 +791,7 @@ public class E2EServiceInstancesTest { public OperationStatus getOperationStatusByServiceId(
String serviceID) {
OperationStatus operationStatus = new OperationStatus();
+ operationStatus.setResult("processing");
return operationStatus;
}
};
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/MsoRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/MsoRequestTest.java index 7963217721..7fb3bf00b0 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/MsoRequestTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/MsoRequestTest.java @@ -25,18 +25,24 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.io.IOException; +import java.io.PrintStream; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; +import mockit.Expectations; +import mockit.Mocked; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.CharEncoding; +import org.hibernate.Session; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.openecomp.mso.apihandler.common.ValidationException; +import org.openecomp.mso.db.AbstractSessionFactoryManager; +import org.openecomp.mso.properties.MsoJavaProperties; import org.openecomp.mso.serviceinstancebeans.ServiceInstancesRequest; import com.fasterxml.jackson.core.JsonParseException; @@ -597,4 +603,22 @@ public class MsoRequestTest { assertNotNull(msoRequest.getRequestId()); assertEquals(msoRequest.getReqVersion(), 6); } + + @Test + public void createRequestRecord(@Mocked AbstractSessionFactoryManager sessionFactoryManager, + @Mocked Session session) throws ValidationException, IOException { + + new Expectations() {{ + sessionFactoryManager.getSessionFactory().openSession(); result = session; + }}; + + this.requestJSON = inputStream("/v6AddRelationships.json"); + this.instanceIdMapTest.put("serviceInstanceId", "ff305d54-75b4-431b-adb2-eb6b9e5ff000"); + this.sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); + this.msoRequest = new MsoRequest ("V6RemoveRelationships"); + msoRequest.parse(sir, instanceIdMapTest, Action.removeRelationships, "v6", originalRequestJSON); + msoRequest.createRequestRecord(Status.COMPLETE, Action.createInstance); + + } + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandlerTest.java index 3c35fed516..2089cf1d32 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandlerTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandlerTest.java @@ -22,6 +22,9 @@ package org.openecomp.mso.apihandlerinfra; import static org.junit.Assert.assertTrue; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; import java.lang.reflect.Field; import java.net.URI; import java.sql.Timestamp; @@ -31,23 +34,44 @@ import java.util.List; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; +import mockit.Expectations; import mockit.Mock; import mockit.MockUp; +import mockit.Mocked; +import org.apache.http.HttpResponse; +import org.apache.http.ProtocolVersion; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.entity.BasicHttpEntity; +import org.apache.http.message.BasicHttpResponse; +import org.hibernate.Session; +import org.junit.AfterClass; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import org.mockito.Mockito; +import org.openecomp.mso.apihandler.common.CamundaClient; import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkRequest; +import org.openecomp.mso.db.AbstractSessionFactoryManager; +import org.openecomp.mso.db.catalog.CatalogDatabase; +import org.openecomp.mso.db.catalog.beans.NetworkRecipe; +import org.openecomp.mso.db.catalog.beans.VfModule; +import org.openecomp.mso.db.catalog.beans.VnfResource; +import org.openecomp.mso.properties.MsoPropertiesFactory; import org.openecomp.mso.requestsdb.InfraActiveRequests; import org.openecomp.mso.requestsdb.InfraRequests; import org.openecomp.mso.requestsdb.RequestsDatabase; public class NetworkRequestHandlerTest { + private static final String REQ_XML = "<network-request xmlns=\"http://org.openecomp/mso/infra/network-request/v1\"> <request-info> <request-id>e1fc3ed3-31e5-48a8-913b-23184c1e9443</request-id><action>CREATE</action> <source>VID</source> <service-instance-id>e1fc3ed3-31e5-48a8-913b-23184c1e9443</service-instance-id></request-info> <network-inputs> <network-id>e1fc3ed3-31e5-48a8-913b-23184c1e9443</network-id> <network-name>nwInstanceName</network-name> <network-type>nwModelName</network-type><modelCustomizationId>e1fc3ed3-31e5-48a8-913b-23184c1e9443</modelCustomizationId> <aic-cloud-region>e1fc3ed3-31e5-48a8-913b-23184c1e9443</aic-cloud-region> <tenant-id>e1fc3ed3-31e5-48a8-913b-23184c1e9443</tenant-id><service-id>e1fc3ed3-31e5-48a8-913b-23184c1e9443</service-id> <backout-on-failure>false</backout-on-failure><sdncVersion>1802</sdncVersion><service-instance-id>e1fc3ed3-31e5-48a8-913b-23184c1e9443</service-instance-id></network-inputs> <network-params></network-params> </network-request>"; + + private static MockUp<RequestsDatabase> mockRDB; + private static MockUp<CatalogDatabase> mockCDB; + private static MockUp<CamundaClient> mockCamundaClient; NetworkRequestHandler handler = null; - -UriInfo uriInfo = null; + UriInfo uriInfo = null; @Before public void setup() throws Exception{ @@ -63,31 +87,112 @@ UriInfo uriInfo = null; f1.set(handler, uriInfo); } + + @BeforeClass + public static void setUp() throws Exception { + MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); + msoPropertiesFactory.removeAllMsoProperties(); + msoPropertiesFactory.initializeMsoProperties(Constants.MSO_PROP_APIHANDLER_INFRA, "src/test/resources/mso.apihandler-infra.properties"); + + mockRDB = new MockUp<RequestsDatabase>() { + @Mock + public InfraActiveRequests checkDuplicateByVnfName (String vnfName, String action, String requestType) { + return null; + } + @Mock + public int updateInfraStatus (String requestId, String requestStatus, long progress, String lastModifiedBy) { + return 1; + } + + @Mock + public int updateInfraFinalStatus (String requestId, String requestStatus, String statusMessage, long progress, String responseBody, String lastModifiedBy) { + return 1; + } + }; + + mockCDB = new MockUp<CatalogDatabase>() { + @Mock + public NetworkRecipe getNetworkRecipe (String networkType, String action, String serviceType) { + final NetworkRecipe networkRecipe = new NetworkRecipe(); + networkRecipe.setOrchestrationUri("test/vnf"); + networkRecipe.setRecipeTimeout(180); + return networkRecipe; + } + + @Mock + public VfModule getVfModuleType(String type, String version) { + final VfModule vfModule = new VfModule(); + return vfModule; + } + + @Mock + public VnfResource getVnfResource (String vnfType, String serviceVersion) { + final VnfResource vnfResource = new VnfResource(); + return vnfResource; + } + }; + + mockCamundaClient = new MockUp<CamundaClient>() { + @Mock + public HttpResponse post(String camundaReqXML, String requestId, + String requestTimeout, String schemaVersion, String serviceInstanceId, String action) + throws ClientProtocolException, IOException { + ProtocolVersion pv = new ProtocolVersion("HTTP",1,1); + HttpResponse resp = new BasicHttpResponse(pv,200, "test response"); + BasicHttpEntity entity = new BasicHttpEntity(); + String body = "{\"response\":\"success\",\"message\":\"success\"}"; + InputStream instream = new ByteArrayInputStream(body.getBytes()); + entity.setContent(instream); + resp.setEntity(entity); + return resp; + } + }; + + } + + @AfterClass + public static void tearDown() { + mockRDB.tearDown(); + mockCDB.tearDown(); + mockCamundaClient.tearDown(); + } @Test - public void manageVnfRequestTest(){ + public void manageVnfRequestTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager, + @Mocked Session session){ + new Expectations() {{ + sessionFactoryManager.getSessionFactory().openSession(); result = session; + }}; Mockito.when(uriInfo.getRequestUri()).thenReturn(URI.create("http://localhost:8080/test")); - Response resp = handler.manageNetworkRequest("<name>Test</name>", "v2"); + Response resp = handler.manageNetworkRequest(REQ_XML, "v2"); assertTrue(null != resp); } @Test - public void manageVnfRequestTestV1(){ + public void manageVnfRequestTestV1(@Mocked AbstractSessionFactoryManager sessionFactoryManager, + @Mocked Session session){ + new Expectations() {{ + sessionFactoryManager.getSessionFactory().openSession(); result = session; + }}; Mockito.when(uriInfo.getRequestUri()).thenReturn(URI.create("http://localhost:8080/test")); - Response resp = handler.manageNetworkRequest("<name>Test</name>", "v1"); + Response resp = handler.manageNetworkRequest(REQ_XML, "v1"); assertTrue(null != resp); } @Test - public void manageVnfRequestTestV3(){ + public void manageVnfRequestTestV3(@Mocked AbstractSessionFactoryManager sessionFactoryManager, + @Mocked Session session){ + new Expectations() {{ + sessionFactoryManager.getSessionFactory().openSession(); result = session; + }}; Mockito.when(uriInfo.getRequestUri()).thenReturn(URI.create("http://localhost:8080/test")); - Response resp = handler.manageNetworkRequest("<name>Test</name>", "v3"); + Response resp = handler.manageNetworkRequest(REQ_XML, "v3"); assertTrue(null != resp); } @Test public void manageVnfRequestTestInvalidVersion(){ - Response resp = handler.manageNetworkRequest("<name>Test</name>", "v249"); + Response resp = handler.manageNetworkRequest(REQ_XML, "v249"); assertTrue(null != resp); } @@ -102,7 +207,7 @@ UriInfo uriInfo = null; return false; } }; - Response resp = handler.manageNetworkRequest("<name>Test</name>", "v2"); + Response resp = handler.manageNetworkRequest(REQ_XML, "v2"); assertTrue(null != resp); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequestsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequestsTest.java index be76d433aa..fa1cce462f 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequestsTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequestsTest.java @@ -183,7 +183,8 @@ public class OrchestrationRequestsTest { Response response = null;
try {
OrchestrationRequests requests = new OrchestrationRequests();
- response = requests.getOrchestrationRequest(new ResteasyUriInfo(new URI("")),"v5");
+ final ResteasyUriInfo ui = new ResteasyUriInfo(new URI("", "", "", "filter=service-instance-id:EQUALS:abc", ""));
+ response = requests.getOrchestrationRequest(ui,"v5");
} finally {
mockUpRDB.tearDown();
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequestTest.java index c8ab6b5612..9a9dec3c27 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequestTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequestTest.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,19 +20,40 @@ package org.openecomp.mso.apihandlerinfra; -import static org.junit.Assert.assertTrue; - +import mockit.Expectations; +import mockit.Mocked; +import mockit.Tested; +import mockit.integration.junit4.JMockit; +import org.hibernate.Session; import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; import org.openecomp.mso.apihandler.common.ValidationException; +import org.openecomp.mso.db.AbstractSessionFactoryManager; import org.openecomp.mso.properties.MsoJavaProperties; +@RunWith(JMockit.class) public class VnfMsoInfraRequestTest { - VnfMsoInfraRequest request = new VnfMsoInfraRequest("29919020"); - - @Test(expected=Exception.class) - public void parseTest() throws ValidationException { - String reqXML = "<vnf-request><request-info> <request-id>29993</request-id><request-status>COMPLETE</request-status></request-info></vnf-request>"; - request.parse(reqXML, "v1", new MsoJavaProperties()); - } - + + VnfMsoInfraRequest request = new VnfMsoInfraRequest("29919020"); + private String reqXML = "<vnf-request xmlns=\"http://org.openecomp/mso/infra/vnf-request/v1\"><request-info><request-id>43b34d6d-1ab2-4c7a-a3a0-5471306550c5</request-id><action>CREATE_VF_MODULE</action><source>VID</source><!-- new 1610 field --><service-instance-id>43b34d6d-1ab2-4c7a-a3a0-5471306550c5</service-instance-id></request-info><vnf-inputs><!-- not in use in 1610 --><vnf-name>vnfName</vnf-name><vnf-type>vnfType</vnf-type><vnf-id>43b34d6d-1ab2-4c7a-a3a0-5471306550c5</vnf-id><volume-group-id>43b34d6d-1ab2-4c7a-a3a0-5471306550c5</volume-group-id><vf-module-id>43b34d6d-1ab2-4c7a-a3a0-5471306550c5</vf-module-id><vf-module-name>vfModuleName</vf-module-name><vf-module-model-name>43b34d6d-1ab2-4c7a-a3a0-5471306550c5</vf-module-model-name><model-customization-id>43b34d6d-1ab2-4c7a-a3a0-5471306550c5</model-customization-id><asdc-service-model-version>43b34d6d-1ab2-4c7a-a3a0-5471306550c5</asdc-service-model-version><aic-cloud-region>43b34d6d-1ab2-4c7a-a3a0-5471306550c5</aic-cloud-region><tenant-id>43b34d6d-1ab2-4c7a-a3a0-5471306550c5</tenant-id><service-id>43b34d6d-1ab2-4c7a-a3a0-5471306550c5</service-id><backout-on-failure>false</backout-on-failure><service-instance-id>43b34d6d-1ab2-4c7a-a3a0-5471306550c5</service-instance-id></vnf-inputs><vnf-params><vnf-parameter-name>pName</vnf-parameter-name><vnf-parameter-value>pValue</vnf-parameter-value></vnf-params></vnf-request>"; + + @Test + public void parseTest() throws ValidationException { + request.parse(reqXML, "v3", new MsoJavaProperties()); + } + + @Test + public void createRequestRecord(@Mocked AbstractSessionFactoryManager sessionFactoryManager, + @Mocked Session session) throws ValidationException { + + new Expectations() {{ + sessionFactoryManager.getSessionFactory().openSession(); result = session; + }}; + + request.parse(reqXML, "v3", new MsoJavaProperties()); + request.createRequestRecord(Status.COMPLETE); + + } + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandlerTest.java index 78ed076b55..ffdf5d40b4 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandlerTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandlerTest.java @@ -22,14 +22,78 @@ package org.openecomp.mso.apihandlerinfra; import static org.junit.Assert.assertTrue; +import mockit.Mock; +import mockit.MockUp; +import org.apache.http.HttpResponse; +import org.apache.http.ProtocolVersion; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.entity.BasicHttpEntity; +import org.apache.http.message.BasicHttpResponse; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Test; +import org.openecomp.mso.apihandler.common.CamundaClient; +import org.openecomp.mso.apihandlerinfra.volumebeans.ActionType; +import org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType; import org.openecomp.mso.apihandlerinfra.volumebeans.VolumeRequest; +import org.openecomp.mso.db.catalog.CatalogDatabase; +import org.openecomp.mso.db.catalog.beans.NetworkRecipe; +import org.openecomp.mso.db.catalog.beans.VfModule; +import org.openecomp.mso.db.catalog.beans.VnfResource; +import org.openecomp.mso.properties.MsoPropertiesFactory; +import org.openecomp.mso.requestsdb.InfraActiveRequests; import org.openecomp.mso.requestsdb.InfraRequests; +import org.openecomp.mso.requestsdb.RequestsDatabase; + +import javax.ws.rs.core.Response; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.Timestamp; +import java.time.LocalDateTime; +import java.util.Collections; +import java.util.List; public class VolumeInfoHandlerTest { VolumeInfoHandler handler = new VolumeInfoHandler(); - + + private static MockUp<RequestsDatabase> mockRDB; + + @BeforeClass + public static void setUp() throws Exception { + MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); + msoPropertiesFactory.removeAllMsoProperties(); + msoPropertiesFactory.initializeMsoProperties(Constants.MSO_PROP_APIHANDLER_INFRA, "src/test/resources/mso.apihandler-infra.properties"); + + mockRDB = new MockUp<RequestsDatabase>() { + @Mock + public List<InfraActiveRequests> getRequestListFromInfraActive (String queryAttributeName, + String queryValue, + String requestType) { + final InfraActiveRequests requests = new InfraActiveRequests(); + requests.setAction(ActionType.CREATE.name()); + requests.setRequestStatus(RequestStatusType.IN_PROGRESS.name()); + requests.setStartTime(Timestamp.valueOf(LocalDateTime.now())); + return Collections.singletonList(requests); + } + @Mock + public InfraActiveRequests getRequestFromInfraActive (String requestId, String requestType) { + final InfraActiveRequests requests = new InfraActiveRequests(); + requests.setAction(ActionType.CREATE.name()); + requests.setRequestStatus(RequestStatusType.IN_PROGRESS.name()); + requests.setStartTime(Timestamp.valueOf(LocalDateTime.now())); + return requests; + } + }; + + } + + @AfterClass + public static void tearDown() { + mockRDB.tearDown(); + } + @Test public void fillVnfRequestTestV3(){ VolumeRequest qr = new VolumeRequest(); @@ -51,4 +115,21 @@ public class VolumeInfoHandlerTest { String vnfid = (String)qr.getVolumeParams(); assertTrue(vnfid.equals("test")); } + + @Test + public void queryFilters() { + final Response response = handler.queryFilters("vnf-type", "svc-type", "aicNode", "tenant-id", + "vg-id", "vg-name", "v3"); + } + + @Test + public void queryFilters2() { + final Response response = handler.queryFilters(null, "svc-type", "aicNode", "tenant-id", + "vg-id", "vg-name", "v3"); + } + + @Test + public void getRequest() { + final Response response = handler.getRequest("request-id", "v3"); + } } diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/InfraRequestsTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/InfraRequestsTest.java new file mode 100644 index 0000000000..33f1fbbb76 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/InfraRequestsTest.java @@ -0,0 +1,129 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : SO +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* ============LICENSE_END========================================================= +*/ +package org.openecomp.mso.requestsdb; + +import static org.junit.Assert.*; + +import java.sql.Timestamp; + +import org.junit.Test; + +public class InfraRequestsTest { + + InfraRequests ir=new InfraRequests(); + InfraRequests ir1=new InfraRequests("requestId", "action"); + Timestamp time=new Timestamp(123); + long progress=111; + @Test + public void test() { + ir.setAaiServiceId("aaiServiceId"); + ir.setAction("action"); + ir.setAicCloudRegion("aicCloudRegion"); + ir.setAicNodeClli("aicNodeClli"); + ir.setCallBackUrl("callBackUrl"); + ir.setClientRequestId("clientRequestId"); + ir.setConfigurationId("configurationId"); + ir.setConfigurationName("configurationName"); + ir.setCorrelator("correlator"); + ir.setEndTime(time); + ir.setLastModifiedBy("lastModifiedBy"); + ir.setModifyTime(time); + ir.setNetworkId("networkId"); + ir.setNetworkName("networkName"); + ir.setNetworkType("networkType"); + ir.setOperationalEnvId("operationalEnvId"); + ir.setOperationalEnvName("operationalEnvName"); + ir.setProgress(progress); + ir.setProvStatus("provStatus"); + ir.setRequestAction("requestAction"); + ir.setRequestBody("requestBody"); + ir.setRequestId("requestId"); + ir.setRequestorId("requestorId"); + ir.setRequestScope("requestScope"); + ir.setRequestStatus("requestStatus"); + ir.setRequestType("requestType"); + ir.setResponseBody("responseBody"); + ir.setServiceInstanceId("serviceInstanceId"); + ir.setServiceInstanceName("serviceInstanceName"); + ir.setServiceType("serviceType"); + ir.setSource("source"); + ir.setStartTime(time); + ir.setStatusMessage("statusMessage"); + ir.setTenantId("tenantId"); + ir.setVfModuleId("vfModuleId"); + ir.setVfModuleModelName("vfModuleModelName"); + ir.setVfModuleName("vfModuleName"); + ir.setVnfId("vnfId"); + ir.setVnfName("vnfName"); + ir.setVnfOutputs("vnfOutputs"); + ir.setVnfParams("vnfParams"); + ir.setVnfType("vnfType"); + ir.setVolumeGroupId("volumeGroupId"); + ir.setVolumeGroupName("volumeGroupName"); + + assertEquals(ir.getAaiServiceId(), "aaiServiceId"); + assertEquals(ir.getAction(),"action"); + assertEquals(ir.getAicCloudRegion(),"aicCloudRegion"); + assertEquals(ir.getAicNodeClli(),"aicNodeClli"); + assertEquals(ir.getCallBackUrl(),"callBackUrl"); + assertEquals(ir.getClientRequestId(),"clientRequestId"); + assertEquals(ir.getConfigurationId(),"configurationId"); + assertEquals(ir.getConfigurationName(),"configurationName"); + assertEquals(ir.getCorrelator(),"correlator"); + assertEquals(ir.getEndTime(),time); + assertEquals(ir.getLastModifiedBy(),"lastModifiedBy"); + assertEquals(ir.getModifyTime(),time); + assertEquals(ir.getNetworkId(),"networkId"); + assertEquals(ir.getNetworkName(),"networkName"); + assertEquals(ir.getNetworkType(),"networkType"); + assertEquals(ir.getOperationalEnvId(),"operationalEnvId"); + assertEquals(ir.getOperationalEnvName(),"operationalEnvName"); + assert(ir.getProgress().equals(progress)); + assertEquals(ir.getProvStatus(),"provStatus"); + assertEquals(ir.getRequestAction(),"requestAction"); + assertEquals(ir.getRequestBody(),"requestBody"); + assertEquals(ir.getRequestId(),"requestId"); + assertEquals(ir.getRequestorId(),"requestorId"); + assertEquals(ir.getRequestScope(),"requestScope"); + assertEquals(ir.getRequestStatus(),"requestStatus"); + assertEquals(ir.getRequestType(),"requestType"); + assertEquals(ir.getResponseBody(),"responseBody"); + assertEquals(ir.getServiceInstanceId(),"serviceInstanceId"); + assertEquals(ir.getServiceInstanceName(),"serviceInstanceName"); + assertEquals(ir.getServiceType(),"serviceType"); + assertEquals(ir.getSource(),"source"); + assertEquals(ir.getStartTime(),time); + assertEquals(ir.getStatusMessage(),"statusMessage"); + assertEquals(ir.getTenantId(),"tenantId"); + assertEquals(ir.getVfModuleId(),"vfModuleId"); + assertEquals(ir.getVfModuleModelName(),"vfModuleModelName"); + assertEquals(ir.getVfModuleName(),"vfModuleName"); + assertEquals(ir.getVnfId(),"vnfId"); + assertEquals(ir.getVnfName(),"vnfName"); + assertEquals(ir.getVnfOutputs(),"vnfOutputs"); + assertEquals(ir.getVnfParams(),"vnfParams"); + assertEquals(ir.getVnfType(),"vnfType"); + assertEquals(ir.getVolumeGroupId(),"volumeGroupId"); + assertEquals(ir.getVolumeGroupName(),"volumeGroupName"); + + } + + +} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationStatusTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationStatusTest.java new file mode 100644 index 0000000000..cf18524ee1 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationStatusTest.java @@ -0,0 +1,61 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : SO +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* ============LICENSE_END========================================================= +*/ +package org.openecomp.mso.requestsdb; + +import static org.junit.Assert.*; +import java.sql.Timestamp; +import org.junit.Test; + +public class OperationStatusTest { + + OperationStatus os=new OperationStatus(); + Timestamp time=new Timestamp(10); + Object obj=new Object(); + @Test + public void test() { + os.setFinishedAt(time); + os.setOperateAt(time); + os.setOperation("operation"); + os.setOperationContent("operationContent"); + os.setOperationId("operationId"); + os.setProgress("progress"); + os.setReason("reason"); + os.setResult("result"); + os.setServiceId("serviceId"); + os.setServiceName("serviceName"); + os.setUserId("userId"); + + assertEquals(os.getFinishedAt(), time); + assertEquals(os.getOperateAt(), time); + assertEquals(os.getOperation(), "operation"); + assertEquals(os.getOperationContent(), "operationContent"); + assertEquals(os.getOperationId(), "operationId"); + assertEquals(os.getProgress(), "progress"); + assertEquals(os.getReason(), "reason"); + assertEquals(os.getResult(), "result"); + assertEquals(os.getServiceId(), "serviceId"); + assertEquals(os.getServiceName(), "serviceName"); + assertEquals(os.getUserId(), "userId"); + + os.equals(obj); + os.hashCode(); + } + +} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatusTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatusTest.java index b0c1c02e7f..6381ec63b9 100644 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatusTest.java +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatusTest.java @@ -1,40 +1,56 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - +/* +* ============LICENSE_START======================================================= +* ONAP : SO +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* ============LICENSE_END========================================================= +*/ package org.openecomp.mso.requestsdb; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.*; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; +import org.junit.Test; +import static org.junit.Assert.assertEquals; import java.sql.Timestamp; public class OperationalEnvDistributionStatusTest { - OperationalEnvDistributionStatus _operationalEnvDistributionStatus; + OperationalEnvDistributionStatus oeds=new OperationalEnvDistributionStatus(); + Timestamp time=new Timestamp(10); + @Test + public void test(){ + oeds.setCreateTime(time); + oeds.setDistributionId("distributionId"); + oeds.setDistributionIdErrorReason("distributionIdErrorReason"); + oeds.setDistributionIdStatus("distributionIdStatus"); + oeds.setModifyTime(time); + oeds.setOperationalEnvId("operationalEnvId"); + oeds.setRequestId("requestId"); + oeds.setServiceModelVersionId("serviceModelVersionId"); + + assertEquals(oeds.getCreateTime(), time); + assertEquals(oeds.getDistributionId(), "distributionId"); + assertEquals(oeds.getDistributionIdErrorReason(), "distributionIdErrorReason"); + assertEquals(oeds.getDistributionIdStatus(), "distributionIdStatus"); + assertEquals(oeds.getModifyTime(),time); + assertEquals(oeds.getOperationalEnvId(), "operationalEnvId"); + assertEquals(oeds.getRequestId(), "requestId"); + assertEquals(oeds.getServiceModelVersionId(), "serviceModelVersionId"); + } +} - protected String _distributionId; + /*protected String _distributionId; protected String _operationalEnvId; protected String _serviceModelVersionId; protected String _requestId; @@ -74,9 +90,9 @@ public class OperationalEnvDistributionStatusTest { _operationalEnvDistributionStatus = null; } - /** + *//** * Test of getDistributionId method - */ + *//* @Test public void testGetDistributionId() { _operationalEnvDistributionStatus.setDistributionId(_distributionId); @@ -84,18 +100,18 @@ public class OperationalEnvDistributionStatusTest { } - /** + *//** * Test setDistributionId method - */ + *//* @Test public void testSetDistributionId() { _operationalEnvDistributionStatus.setDistributionId(_distributionId); verify(_operationalEnvDistributionStatus).setDistributionId(_distributionId); } - /** + *//** * Test of getOperationalEnvId method - */ + *//* @Test public void testGetOperationalEnvId() { _operationalEnvDistributionStatus.setOperationalEnvId(_operationalEnvId); @@ -103,18 +119,18 @@ public class OperationalEnvDistributionStatusTest { } - /** + *//** * Test setOperationalEnvId method - */ + *//* @Test public void testSetOperationalEnvId() { _operationalEnvDistributionStatus.setOperationalEnvId(_operationalEnvId); verify(_operationalEnvDistributionStatus).setOperationalEnvId(_operationalEnvId); } - /** + *//** * Test of getServiceModelVersionId method - */ + *//* @Test public void testGetServiceModelVersionId() { _operationalEnvDistributionStatus.setServiceModelVersionId(_serviceModelVersionId); @@ -122,18 +138,18 @@ public class OperationalEnvDistributionStatusTest { } - /** + *//** * Test setServiceModelVersionId method - */ + *//* @Test public void testSetServiceModelVersionId() { _operationalEnvDistributionStatus.setServiceModelVersionId(_serviceModelVersionId); verify(_operationalEnvDistributionStatus).setServiceModelVersionId(_serviceModelVersionId); } - /** + *//** * Test of getRequestId method - */ + *//* @Test public void testGetRequestId() { _operationalEnvDistributionStatus.setRequestId(_requestId); @@ -141,18 +157,18 @@ public class OperationalEnvDistributionStatusTest { } - /** + *//** * Test setRequestId method - */ + *//* @Test public void testSetRequestId() { _operationalEnvDistributionStatus.setRequestId(_requestId); verify(_operationalEnvDistributionStatus).setRequestId(_requestId); } - /** + *//** * Test of getDistributionIdStatus method - */ + *//* @Test public void testGetDistributionIdStatus() { _operationalEnvDistributionStatus.setDistributionIdStatus(_distributionIdStatus); @@ -160,18 +176,18 @@ public class OperationalEnvDistributionStatusTest { } - /** + *//** * Test setDistributionIdStatus method - */ + *//* @Test public void testSetDistributionIdStatus() { _operationalEnvDistributionStatus.setDistributionIdStatus(_distributionIdStatus); verify(_operationalEnvDistributionStatus).setDistributionIdStatus(_distributionIdStatus); } - /** + *//** * Test of getDistributionIdErrorReason method - */ + *//* @Test public void testGetDistributionIdErrorReason() { _operationalEnvDistributionStatus.setDistributionIdErrorReason(_distributionIdErrorReason); @@ -179,18 +195,18 @@ public class OperationalEnvDistributionStatusTest { } - /** + *//** * Test setDistributionIdErrorReason method - */ + *//* @Test public void testSetDistributionIdErrorReason() { _operationalEnvDistributionStatus.setDistributionIdErrorReason(_distributionIdErrorReason); verify(_operationalEnvDistributionStatus).setDistributionIdErrorReason(_distributionIdErrorReason); } - /** + *//** * Test of getCreateTime method - */ + *//* @Test public void testGetCreateTime() { _operationalEnvDistributionStatus.setCreateTime(_createTime); @@ -199,18 +215,18 @@ public class OperationalEnvDistributionStatusTest { } - /** + *//** * Test setCreateTime method - */ + *//* @Test public void testSetCreateTime() { _operationalEnvDistributionStatus.setCreateTime(_createTime); verify(_operationalEnvDistributionStatus).setCreateTime(_createTime); } - /** + *//** * Test of getModifyTime method - */ + *//* @Test public void testGetModifyTime() { _operationalEnvDistributionStatus.setModifyTime(_modifyTime); @@ -219,9 +235,9 @@ public class OperationalEnvDistributionStatusTest { } - /** + *//** * Test setModifyTime method - */ + *//* @Test public void testSetModifyTime() { _operationalEnvDistributionStatus.setModifyTime(_modifyTime); @@ -230,3 +246,4 @@ public class OperationalEnvDistributionStatusTest { } +*/
\ No newline at end of file diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatusTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatusTest.java index eb6a9f1d82..ecde7b36f6 100644 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatusTest.java +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatusTest.java @@ -1,39 +1,57 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ +/* +* ============LICENSE_START======================================================= +* ONAP : SO +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* ============LICENSE_END========================================================= +*/ package org.openecomp.mso.requestsdb; import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - import java.sql.Timestamp; - -import org.junit.After; -import org.junit.Before; import org.junit.Test; public class OperationalEnvServiceModelStatusTest { - OperationalEnvServiceModelStatus _operationalEnvServiceModelStatus; + OperationalEnvServiceModelStatus oesms=new OperationalEnvServiceModelStatus(); + Timestamp time=new Timestamp(10); + @Test + public void test(){ + oesms.setCreateTime(time); + oesms.setModifyTime(time); + oesms.setOperationalEnvId("operationalEnvId"); + oesms.setRecoveryAction("recoveryAction"); + oesms.setRequestId("requestId"); + oesms.setRetryCount(0); + oesms.setServiceModelVersionDistrStatus("serviceModelVersionDistrStatus"); + oesms.setServiceModelVersionId("serviceModelVersionId"); + oesms.setWorkloadContext("workloadContext"); + + assertEquals(oesms.getCreateTime(), time); + assertEquals(oesms.getModifyTime(), time); + assertEquals(oesms.getOperationalEnvId(), "operationalEnvId"); + assertEquals(oesms.getRecoveryAction(), "recoveryAction"); + assertEquals(oesms.getRequestId(), "requestId"); + assertEquals(oesms.getRetryCount(), 0); + assertEquals(oesms.getServiceModelVersionDistrStatus(), "serviceModelVersionDistrStatus"); + assertEquals(oesms.getServiceModelVersionId(), "serviceModelVersionId"); + assertEquals(oesms.getWorkloadContext(), "workloadContext"); + } +} + /*OperationalEnvServiceModelStatus _operationalEnvServiceModelStatus; protected String _requestId; protected String _operationalEnvId; @@ -79,9 +97,9 @@ public class OperationalEnvServiceModelStatusTest { _operationalEnvServiceModelStatus = null; } - /** + *//** * Test of getRequestId method - */ + *//* @Test public void testGetRequestId() { _operationalEnvServiceModelStatus.setRequestId(_requestId); @@ -89,18 +107,18 @@ public class OperationalEnvServiceModelStatusTest { } - /** + *//** * Test setRequestId method - */ + *//* @Test public void testSetRequestId() { _operationalEnvServiceModelStatus.setRequestId(_requestId); verify(_operationalEnvServiceModelStatus).setRequestId(_requestId); } - /** + *//** * Test of getOperationalEnvId method - */ + *//* @Test public void testGetOperationalEnvId() { _operationalEnvServiceModelStatus.setOperationalEnvId(_operationalEnvId); @@ -108,18 +126,18 @@ public class OperationalEnvServiceModelStatusTest { } - /** + *//** * Test setOperationalEnvId method - */ + *//* @Test public void testSetOperationalEnvId() { _operationalEnvServiceModelStatus.setOperationalEnvId(_operationalEnvId); verify(_operationalEnvServiceModelStatus).setOperationalEnvId(_operationalEnvId); } - /** + *//** * Test of getServiceModelVersionId method - */ + *//* @Test public void testGetServiceModelVersionId() { _operationalEnvServiceModelStatus.setServiceModelVersionId(_serviceModelVersionId); @@ -127,18 +145,18 @@ public class OperationalEnvServiceModelStatusTest { } - /** + *//** * Test setServiceModelVersionId method - */ + *//* @Test public void testSetServiceModelVersionId() { _operationalEnvServiceModelStatus.setServiceModelVersionId(_serviceModelVersionId); verify(_operationalEnvServiceModelStatus).setServiceModelVersionId(_serviceModelVersionId); } - /** + *//** * Test of getServiceModelVersionId method - */ + *//* @Test public void testGetServiceModelVersionDistrStatus() { _operationalEnvServiceModelStatus.setServiceModelVersionDistrStatus(_serviceModelVersionDistrStatus); @@ -146,18 +164,18 @@ public class OperationalEnvServiceModelStatusTest { } - /** + *//** * Test setServiceModelVersionId method - */ + *//* @Test public void testSetServiceModelVersionDistrStatus() { _operationalEnvServiceModelStatus.setServiceModelVersionDistrStatus(_serviceModelVersionDistrStatus); verify(_operationalEnvServiceModelStatus).setServiceModelVersionDistrStatus(_serviceModelVersionDistrStatus); } - /** + *//** * Test of getOperationalEnvId method - */ + *//* @Test public void testGetRecoveryAction() { _operationalEnvServiceModelStatus.setRecoveryAction(_recoveryAction); @@ -165,18 +183,18 @@ public class OperationalEnvServiceModelStatusTest { } - /** + *//** * Test setOperationalEnvId method - */ + *//* @Test public void testSetRecoveryAction() { _operationalEnvServiceModelStatus.setRecoveryAction(_recoveryAction); verify(_operationalEnvServiceModelStatus).setRecoveryAction(_recoveryAction); } - /** + *//** * Test of getOperationalEnvId method - */ + *//* @Test public void testGetRetryCount() { _operationalEnvServiceModelStatus.setRetryCount(_retryCount); @@ -184,18 +202,18 @@ public class OperationalEnvServiceModelStatusTest { } - /** + *//** * Test setOperationalEnvId method - */ + *//* @Test public void testSetRetryCount() { _operationalEnvServiceModelStatus.setRetryCount(_retryCount); verify(_operationalEnvServiceModelStatus).setRetryCount(_retryCount); } - /** + *//** * Test of getOperationalEnvId method - */ + *//* @Test public void testGetWorkloadContext() { _operationalEnvServiceModelStatus.setWorkloadContext(_workloadContext); @@ -203,18 +221,18 @@ public class OperationalEnvServiceModelStatusTest { } - /** + *//** * Test setOperationalEnvId method - */ + *//* @Test public void testSetWorkloadContext() { _operationalEnvServiceModelStatus.setWorkloadContext(_workloadContext); verify(_operationalEnvServiceModelStatus).setWorkloadContext(_workloadContext); } - /** + *//** * Test of getCreateTime method - */ + *//* @Test public void testGetCreateTime() { _operationalEnvServiceModelStatus.setCreateTime(_createTime); @@ -222,18 +240,18 @@ public class OperationalEnvServiceModelStatusTest { } - /** + *//** * Test setCreateTime method - */ + *//* @Test public void testSetCreateTime() { _operationalEnvServiceModelStatus.setCreateTime(_createTime); verify(_operationalEnvServiceModelStatus).setCreateTime(_createTime); } - /** + *//** * Test of getModifyTime method - */ + *//* @Test public void testGetModifyTime() { _operationalEnvServiceModelStatus.setModifyTime(_modifyTime); @@ -241,13 +259,13 @@ public class OperationalEnvServiceModelStatusTest { } - /** + *//** * Test setModifyTime method - */ + *//* @Test public void testSetModifyTime() { _operationalEnvServiceModelStatus.setModifyTime(_modifyTime); verify(_operationalEnvServiceModelStatus).setModifyTime(_modifyTime); } - -} + */ + diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/ResourceOperationStatusTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/ResourceOperationStatusTest.java new file mode 100644 index 0000000000..a9773c3bae --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/ResourceOperationStatusTest.java @@ -0,0 +1,58 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : SO +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* ============LICENSE_END========================================================= +*/ +package org.openecomp.mso.requestsdb; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class ResourceOperationStatusTest { + + ResourceOperationStatus ros=new ResourceOperationStatus(); + ResourceOperationStatus ros1=new ResourceOperationStatus("serviceId", "operationId", "resourceTemplateUUID"); + Object obj=new Object(); + @Test + public void test() { + ros.setErrorCode("errorCode"); + ros.setJobId("jobId"); + ros.setOperationId("operationId"); + ros.setOperType("operType"); + ros.setProgress("progress"); + ros.setResourceInstanceID("resourceInstanceID"); + ros.setResourceTemplateUUID("resourceTemplateUUId"); + ros.setServiceId("serviceId"); + ros.setStatus("101"); + ros.setStatusDescription("statusDescription"); + + assertEquals(ros.getErrorCode(), "errorCode"); + assertEquals(ros.getJobId(), "jobId"); + assertEquals(ros.getOperationId(), "operationId"); + assertEquals(ros.getOperType(), "operType"); + assertEquals(ros.getProgress(), "progress"); + assertEquals(ros.getResourceInstanceID(), "resourceInstanceID"); + assertEquals(ros.getResourceTemplateUUID(), "resourceTemplateUUId"); + assertEquals(ros.getServiceId(), "serviceId"); + assertEquals(ros.getStatus(), "101"); + assertEquals(ros.getStatusDescription(), "statusDescription"); + ros.equals(obj); + ros.hashCode(); + } + +} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/SiteStatusTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/SiteStatusTest.java new file mode 100644 index 0000000000..b989dac262 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/SiteStatusTest.java @@ -0,0 +1,44 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : SO +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* ============LICENSE_END========================================================= +*/ +package org.openecomp.mso.requestsdb; + +import static org.junit.Assert.*; +import java.sql.Timestamp; +import org.junit.Test; + +public class SiteStatusTest { + + SiteStatus ss=new SiteStatus(); + Timestamp time=new Timestamp(10); + @Test + public void test() { + ss.setCreated(time); + ss.setSiteName("siteName"); + ss.setStatus(true); + + assertEquals(ss.getCreated(), time); + assertEquals(ss.getSiteName(), "siteName"); + assertEquals(ss.getStatus(), true); + } + @Test + public void testToString(){ + assert(ss.toString()!=null); + } +} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatusTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatusTest.java index b36166942d..0d68c12a0a 100644 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatusTest.java +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatusTest.java @@ -1,39 +1,50 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - +/* +* ============LICENSE_START======================================================= +* ONAP : SO +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* ============LICENSE_END========================================================= +*/ package org.openecomp.mso.requestsdb; import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - import java.sql.Timestamp; - -import org.junit.After; -import org.junit.Before; import org.junit.Test; public class WatchdogComponentDistributionStatusTest { + + WatchdogComponentDistributionStatus wcds=new WatchdogComponentDistributionStatus(); + Timestamp time=new Timestamp(10); + + @Test + public void test(){ + wcds.setComponentDistributionStatus("componentDistributionStatus"); + wcds.setComponentName("componentName"); + wcds.setCreateTime(time); + wcds.setDistributionId("distributionId"); + wcds.setModifyTime(time); + + assertEquals(wcds.getComponentDistributionStatus(), "componentDistributionStatus"); + assertEquals(wcds.getComponentName(), "componentName"); + assertEquals(wcds.getCreateTime(), time); + assertEquals(wcds.getDistributionId(), "distributionId"); + assertEquals(wcds.getModifyTime(), time); + } +} - WatchdogComponentDistributionStatus _watchdogComponentDistributionStatus; + /*WatchdogComponentDistributionStatus _watchdogComponentDistributionStatus; protected String _distributionId; protected String _componentName; @@ -65,9 +76,9 @@ public class WatchdogComponentDistributionStatusTest { _watchdogComponentDistributionStatus = null; } - /** + *//** * Test of getDistributionId method - */ + *//* @Test public void testGetDistributionId() { _watchdogComponentDistributionStatus.setDistributionId(_distributionId); @@ -75,18 +86,18 @@ public class WatchdogComponentDistributionStatusTest { } - /** + *//** * Test setDistributionId method - */ + *//* @Test public void testSetDistributionId() { _watchdogComponentDistributionStatus.setDistributionId(_distributionId); verify(_watchdogComponentDistributionStatus).setDistributionId(_distributionId); } - /** + *//** * Test of getDistributionId method - */ + *//* @Test public void testGetComponentName() { _watchdogComponentDistributionStatus.setComponentName(_componentName); @@ -94,18 +105,18 @@ public class WatchdogComponentDistributionStatusTest { } - /** + *//** * Test setDistributionId method - */ + *//* @Test public void testSetComponentName() { _watchdogComponentDistributionStatus.setComponentName(_componentName); verify(_watchdogComponentDistributionStatus).setComponentName(_componentName); } - /** + *//** * Test of getDistributionId method - */ + *//* @Test public void testGetComponentDistributionStatus() { _watchdogComponentDistributionStatus.setComponentDistributionStatus(_componentDistributionStatus); @@ -113,18 +124,18 @@ public class WatchdogComponentDistributionStatusTest { } - /** + *//** * Test setDistributionId method - */ + *//* @Test public void testSetComponentDistributionStatus() { _watchdogComponentDistributionStatus.setComponentDistributionStatus(_componentDistributionStatus); verify(_watchdogComponentDistributionStatus).setComponentDistributionStatus(_componentDistributionStatus); } - /** + *//** * Test of getCreateTime method - */ + *//* @Test public void testGetCreateTime() { _watchdogComponentDistributionStatus.setCreateTime(_createTime); @@ -133,18 +144,18 @@ public class WatchdogComponentDistributionStatusTest { } - /** + *//** * Test setCreateTime method - */ + *//* @Test public void testSetCreateTime() { _watchdogComponentDistributionStatus.setCreateTime(_createTime); verify(_watchdogComponentDistributionStatus).setCreateTime(_createTime); } - /** + *//** * Test of getModifyTime method - */ + *//* @Test public void testGetModifyTime() { _watchdogComponentDistributionStatus.setModifyTime(_modifyTime); @@ -153,9 +164,9 @@ public class WatchdogComponentDistributionStatusTest { } - /** + *//** * Test setModifyTime method - */ + *//* @Test public void testSetModifyTime() { _watchdogComponentDistributionStatus.setModifyTime(_modifyTime); @@ -163,3 +174,4 @@ public class WatchdogComponentDistributionStatusTest { } } +*/
\ No newline at end of file diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatusTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatusTest.java index 85ac4bba4a..c10d7ae15b 100644 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatusTest.java +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatusTest.java @@ -1,39 +1,49 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ +/* +* ============LICENSE_START======================================================= +* ONAP : SO +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* ============LICENSE_END========================================================= +*/ package org.openecomp.mso.requestsdb; import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - import java.sql.Timestamp; - -import org.junit.After; -import org.junit.Before; import org.junit.Test; public class WatchdogDistributionStatusTest { + + WatchdogDistributionStatus wds=new WatchdogDistributionStatus(); + Timestamp time=new Timestamp(10); + @Test + public void test() { + wds.setCreateTime(time); + wds.setDistributionId("distributionId"); + wds.setDistributionIdStatus("distributionIdStatus"); + wds.setModifyTime(time); + + assertEquals(wds.getCreateTime(), time); + assertEquals(wds.getDistributionId(), "distributionId"); + assertEquals(wds.getDistributionIdStatus(), "distributionIdStatus"); + assertEquals(wds.getModifyTime(), time); - WatchdogDistributionStatus _watchdogDistributionStatus; + } + + +/* WatchdogDistributionStatus _watchdogDistributionStatus; protected String _distributionId; protected String _distributionIdStatus; @@ -62,9 +72,9 @@ public class WatchdogDistributionStatusTest { _watchdogDistributionStatus = null; } - /** + *//** * Test of getDistributionId method - */ + *//* @Test public void testGetDistributionId() { _watchdogDistributionStatus.setDistributionId(_distributionId); @@ -72,18 +82,18 @@ public class WatchdogDistributionStatusTest { } - /** + *//** * Test setDistributionId method - */ + *//* @Test public void testSetDistributionId() { _watchdogDistributionStatus.setDistributionId(_distributionId); verify(_watchdogDistributionStatus).setDistributionId(_distributionId); } - /** + *//** * Test of getDistributionIdStatus method - */ + *//* @Test public void testGetComponentDistributionStatus() { _watchdogDistributionStatus.setDistributionIdStatus(_distributionIdStatus); @@ -91,18 +101,18 @@ public class WatchdogDistributionStatusTest { } - /** + *//** * Test setDistributionIdStatus method - */ + *//* @Test public void testSetComponentDistributionStatus() { _watchdogDistributionStatus.setDistributionIdStatus(_distributionIdStatus); verify(_watchdogDistributionStatus).setDistributionIdStatus(_distributionIdStatus); } - /** + *//** * Test of getCreateTime method - */ + *//* @Test public void testGetCreateTime() { _watchdogDistributionStatus.setCreateTime(_createTime); @@ -110,18 +120,18 @@ public class WatchdogDistributionStatusTest { } - /** + *//** * Test setCreateTime method - */ + *//* @Test public void testSetCreateTime() { _watchdogDistributionStatus.setCreateTime(_createTime); verify(_watchdogDistributionStatus).setCreateTime(_createTime); } - /** + *//** * Test of getModifyTime method - */ + *//* @Test public void testGetModifyTime() { _watchdogDistributionStatus.setModifyTime(_modifyTime); @@ -129,12 +139,12 @@ public class WatchdogDistributionStatusTest { } - /** + *//** * Test setModifyTime method - */ + *//* @Test public void testSetModifyTime() { _watchdogDistributionStatus.setModifyTime(_modifyTime); verify(_watchdogDistributionStatus).setModifyTime(_modifyTime); - } + }*/ } diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookupTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookupTest.java index beda191194..d27c1b817e 100644 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookupTest.java +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookupTest.java @@ -1,39 +1,45 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ +/* +* ============LICENSE_START======================================================= +* ONAP : SO +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* ============LICENSE_END========================================================= +*/ package org.openecomp.mso.requestsdb; import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - import java.sql.Timestamp; - -import org.junit.After; -import org.junit.Before; import org.junit.Test; public class WatchdogServiceModVerIdLookupTest { - - WatchdogServiceModVerIdLookup _watchdogServiceModVerIdLookup; + + WatchdogServiceModVerIdLookup wsmil=new WatchdogServiceModVerIdLookup(); + Timestamp time=new Timestamp(10); + @Test + public void test(){ + wsmil.setCreateTime(time); + wsmil.setDistributionId("distributionId"); + wsmil.setServiceModelVersionId("serviceModelVersionId"); + + assertEquals(wsmil.getCreateTime(),time); + assertEquals(wsmil.getDistributionId(), "distributionId"); + assertEquals(wsmil.getServiceModelVersionId(), "serviceModelVersionId"); + } +} +/*WatchdogServiceModVerIdLookup _watchdogServiceModVerIdLookup; protected String _distributionId; protected String _serviceModelVersionId; @@ -58,9 +64,9 @@ public class WatchdogServiceModVerIdLookupTest { _watchdogServiceModVerIdLookup = null; } - /** + *//** * Test of getDistributionId method - */ + *//* @Test public void testGetDistributionId() { _watchdogServiceModVerIdLookup.setDistributionId(_distributionId); @@ -68,18 +74,18 @@ public class WatchdogServiceModVerIdLookupTest { } - /** + *//** * Test setDistributionId method - */ + *//* @Test public void testSetDistributionId() { _watchdogServiceModVerIdLookup.setDistributionId(_distributionId); verify(_watchdogServiceModVerIdLookup).setDistributionId(_distributionId); } - /** + *//** * Test of getServiceModelVersionId method - */ + *//* @Test public void testGetServiceModelVersionId() { _watchdogServiceModVerIdLookup.setServiceModelVersionId(_serviceModelVersionId); @@ -87,18 +93,18 @@ public class WatchdogServiceModVerIdLookupTest { } - /** + *//** * Test setServiceModelVersionId method - */ + *//* @Test public void testSetServiceModelVersionId() { _watchdogServiceModVerIdLookup.setServiceModelVersionId(_serviceModelVersionId); verify(_watchdogServiceModVerIdLookup).setServiceModelVersionId(_serviceModelVersionId); } - /** + *//** * Test of getCreateTime method - */ + *//* @Test public void testGetCreateTime() { _watchdogServiceModVerIdLookup.setCreateTime(_createTime); @@ -106,13 +112,13 @@ public class WatchdogServiceModVerIdLookupTest { } - /** + *//** * Test setCreateTime method - */ + *//* @Test public void testSetCreateTime() { _watchdogServiceModVerIdLookup.setCreateTime(_createTime); verify(_watchdogServiceModVerIdLookup).setCreateTime(_createTime); } -}
\ No newline at end of file +}*/
\ No newline at end of file |