aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/java/org/onap/vid/controller/OperationalEnvironmentController.java
diff options
context:
space:
mode:
authorMichal Kabaj <michal.kabaj@nokia.com>2019-03-23 00:10:14 +0100
committerMichal Kabaj <michal.kabaj@nokia.com>2019-03-23 00:10:14 +0100
commit59b3997941ecf730beaa979c17ff6c9d303c87d5 (patch)
tree190379b7335d56ff180ddc159e3087f659801410 /vid-app-common/src/main/java/org/onap/vid/controller/OperationalEnvironmentController.java
parent926100a4e3d59d0dbee1f79570fca98d177d323b (diff)
ControllerUtils tests and improvements
- added junits - Injecting SystemPropertiesWrapper via constructor - switched extractUserId is now instance method instead of static Change-Id: Ic706b780c64248e44207a1dee723981a4ca7ed74 Issue-ID: VID-449 Signed-off-by: Michal Kabaj <michal.kabaj@nokia.com>
Diffstat (limited to 'vid-app-common/src/main/java/org/onap/vid/controller/OperationalEnvironmentController.java')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/OperationalEnvironmentController.java11
1 files changed, 7 insertions, 4 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/OperationalEnvironmentController.java b/vid-app-common/src/main/java/org/onap/vid/controller/OperationalEnvironmentController.java
index fe94dfd80..a6778ad0c 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/OperationalEnvironmentController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/OperationalEnvironmentController.java
@@ -37,6 +37,7 @@ import org.onap.vid.mso.model.OperationalEnvironmentActivateInfo;
import org.onap.vid.mso.model.OperationalEnvironmentDeactivateInfo;
import org.onap.vid.mso.rest.OperationalEnvironment.OperationEnvironmentRequestDetails;
import org.onap.vid.mso.rest.RequestDetails;
+import org.onap.vid.utils.SystemPropertiesWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.MissingServletRequestParameterException;
@@ -60,20 +61,22 @@ public class OperationalEnvironmentController extends VidRestrictedBaseControlle
private final MsoInterface restMso;
private final MsoBusinessLogic msoBusinessLogic;
+ private final SystemPropertiesWrapper systemPropertiesWrapper;
private static final Pattern RECOVERY_ACTION_MESSAGE_PATTERN = Pattern.compile("from String \"(.*)\": value not");
@Autowired
- public OperationalEnvironmentController(MsoBusinessLogic msoBusinessLogic, MsoInterface msoClientInterface) {
+ public OperationalEnvironmentController(MsoBusinessLogic msoBusinessLogic, MsoInterface msoClientInterface, SystemPropertiesWrapper systemPropertiesWrapper) {
this.restMso = msoClientInterface;
this.msoBusinessLogic = msoBusinessLogic;
+ this.systemPropertiesWrapper = systemPropertiesWrapper;
}
@RequestMapping(value = "/create", method = RequestMethod.POST)
public MsoResponseWrapper2 createOperationalEnvironment(HttpServletRequest request, @RequestBody OperationalEnvironmentCreateBody operationalEnvironment) {
debugStart(operationalEnvironment);
- String userId = ControllersUtils.extractUserId(request);
+ String userId = new ControllersUtils(systemPropertiesWrapper).extractUserId(request);
RequestDetailsWrapper<OperationEnvironmentRequestDetails> requestDetailsWrapper = msoBusinessLogic.convertParametersToRequestDetails(operationalEnvironment, userId);
String path = msoBusinessLogic.getOperationalEnvironmentCreationPath();
@@ -94,7 +97,7 @@ public class OperationalEnvironmentController extends VidRestrictedBaseControlle
throw new BadManifestException("Manifest structure is wrong");
}
- String userId = ControllersUtils.extractUserId(request);
+ String userId = new ControllersUtils(systemPropertiesWrapper).extractUserId(request);
OperationalEnvironmentActivateInfo activateInfo = new OperationalEnvironmentActivateInfo(activateRequest, userId, operationalEnvironmentId);
debugStart(activateInfo);
@@ -115,7 +118,7 @@ public class OperationalEnvironmentController extends VidRestrictedBaseControlle
verifyIsNotEmpty(operationalEnvironmentId, "operationalEnvironment");
- String userId = ControllersUtils.extractUserId(request);
+ String userId = new ControllersUtils(systemPropertiesWrapper).extractUserId(request);
OperationalEnvironmentDeactivateInfo deactivateInfo = new OperationalEnvironmentDeactivateInfo(userId, operationalEnvironmentId);
debugStart(deactivateInfo);