From 8fa77ad4d4c2498e40a4c23e6826d9ad73a1dab8 Mon Sep 17 00:00:00 2001 From: Tomasz Golabek Date: Thu, 4 Apr 2019 17:52:26 +0200 Subject: Some unit tests for catalog-be Code coverage for some classes from catalog-be increased. Some refactor made if needed. Change-Id: I5cd63fe61425f5eb05336545d714cbe2df83e116 Issue-ID: SDC-2220 Signed-off-by: Tomasz Golabek --- .../components/validation/AccessValidations.java | 26 ++++++++++++---------- .../openecomp/sdc/be/info/ArtifactAccessInfo.java | 4 +--- 2 files changed, 15 insertions(+), 15 deletions(-) (limited to 'catalog-be/src/main/java') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/AccessValidations.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/AccessValidations.java index 335a9398d7..28723f6c29 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/AccessValidations.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/AccessValidations.java @@ -14,7 +14,6 @@ public class AccessValidations { private final UserValidations userValidations; private final ComponentValidations componentValidations; - public AccessValidations(UserValidations userValidations, ComponentValidations componentValidations) { this.userValidations = userValidations; this.componentValidations = componentValidations; @@ -31,8 +30,16 @@ public class AccessValidations { validateUserIsAdminOrDesigner(user); return componentValidations.validateComponentIsCheckedOutByUser(componentId, componentType, userId); } - private User retrieveUser(String userId, String actionContext) { - return userValidations.validateUserExists(userId, actionContext, true); + + + public void validateUserCanWorkOnComponent(Component component, String userId, String actionContext) { + User user = retrieveUser(userId, actionContext); + validateUserIsAdminOrDesigner(user); + componentValidations.validateComponentIsCheckedOutByUser(component, userId); + } + + public void validateUserExists(String userId, String context) { + retrieveUser(userId, context); } public void validateUserExist(String userId, String actionContext) { @@ -45,6 +52,10 @@ public class AccessValidations { return user; } + private User retrieveUser(String userId, String actionContext) { + return userValidations.validateUserExists(userId, actionContext, true); + } + private void validateUserIsAdminOrDesigner(User user) { List roles = new ArrayList<>(2); roles.add(Role.ADMIN); @@ -52,13 +63,4 @@ public class AccessValidations { userValidations.validateUserRole(user, roles); } - public void validateUserCanWorkOnComponent(Component component, String userId, String actionContext) { - User user = retrieveUser(userId, actionContext); - validateUserIsAdminOrDesigner(user); - componentValidations.validateComponentIsCheckedOutByUser(component, userId); - } - - public void validateUserExists(String userId, String context) { - retrieveUser(userId, context); - } } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/info/ArtifactAccessInfo.java b/catalog-be/src/main/java/org/openecomp/sdc/be/info/ArtifactAccessInfo.java index bedbff46b1..490684e20d 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/info/ArtifactAccessInfo.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/info/ArtifactAccessInfo.java @@ -35,10 +35,8 @@ public class ArtifactAccessInfo { urlBuilder = urlBuilder.append(servletContext).append("/"); urlBuilder.append("resources/") // .append(artifactData.getResourceId()).append("/") - - .append("/artifacts/"); + .append("artifacts/"); this.url = urlBuilder.toString(); - } private String name; -- cgit 1.2.3-korg