summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-BE-common
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-portal-BE-common')
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/music/util/MusicProperties.java38
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAccessRolesController.java9
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WebAnalyticsExtAppController.java4
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/ecomp/model/AppContactUsItem.java2
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/interceptor/PortalResourceInterceptor.java37
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/listener/HealthMonitor.java3
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/aop/EPEELFLoggerAdvice.java175
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/logic/AuxDiscriminator.java74
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxUtil.java19
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ApplicationsRestClientServiceImpl.java44
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AppsCacheService.java6
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AppsCacheServiceImple.java42
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPRoleFunctionServiceCentralizedImpl.java7
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImpl.java20
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserServiceImpl.java9
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/EpNotificationItemVO.java4
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/RemoteRoleV1.java4
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EPCommonSystemProperties.java7
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EcompPortalUtils.java18
-rw-r--r--ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/EP.hbm.xml4
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/music/util/MusicUtilTest.java52
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/ExternalAccessRolesControllerTest.java6
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/UserNotificationControllerTest.java57
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/UserRolesControllerTest.java131
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WebAnalyticsExtAppControllerTest.java29
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/BEPropertyTest.java69
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/CentralRoleFunctionTest.java2
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPAppTest.java173
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPUserAppRolesRequestTest.java94
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/ExternalSystemAccessTest.java21
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/listener/UserSessionListenerTest.java99
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/logging/logic/AuxDiscriminatorTest.java98
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/model/AppCategoryFunctionsItemTest.java47
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/model/AppContactUsItemTest.java61
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/scheduler/SchedulerResponseWrapperTest.java58
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/scheduler/util/CustomJacksonJaxBJsonProviderTest.java52
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxRestIntTest.java60
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxUtilTest.java82
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/AppContactUsServiceImplTest.java47
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/BasicAuthAccountServiceImplTest.java13
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/ConsulHealthServiceImplTest.java184
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/MicroserviceServiceImplTest.java72
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/UserServiceImplTest.java214
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralAppTest.java79
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralRoleFunctionTest.java94
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralUserAppTest.java50
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralV2UserTest.java267
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/EPUserAppCurrentRolesTest.java35
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/EcompUserRolesTest.java112
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/EpNotificationItemTest.java132
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/EpNotificationItemVOTest.java80
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/ExternalRoleDescriptionTest.java65
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/FieldsValidatorTest.java79
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/FunctionalMenuItemTest.java28
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/RemoteRoleTest.java44
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/RemoteRoleV1Test.java33
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/UserWithNameSurnameTitleTest.java27
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/utils/HashMapFromListTest.java155
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/service/sessionmgt/ManageServiceTest.java101
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/service/sessionmgt/SessionCommunicationTest.java14
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/uebhandler/MainUebHandlerTest.java75
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/uebhandler/WidgetNotificationHandlerTest.java93
62 files changed, 3269 insertions, 541 deletions
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/music/util/MusicProperties.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/music/util/MusicProperties.java
index 5ff22635..e867deb1 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/music/util/MusicProperties.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/music/util/MusicProperties.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright © 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -186,4 +186,40 @@ public class MusicProperties {
}
return true;
}
+
+ /**
+ * Tests whether a property value is available for the specified key.
+ *
+ * @param key
+ * Property key
+ * @return True if the key is known, otherwise false.
+ */
+/* public static boolean containsProperty(String key) {
+ return environment.containsProperty(key);
+ }*/
+
+ /**
+ * Returns the property value associated with the given key (never
+ * {@code null}), after trimming any trailing space.
+ *
+ * @param key
+ * Property key
+ * @return Property value; the empty string if the environment was not
+ * autowired, which should never happen.
+ * @throws IllegalStateException
+ * if the key is not found
+ */
+/* public static String getProperty(String key) {
+ String value = "";
+ if (environment == null) {
+ // logger.error(EELFLoggerDelegate.errorLogger, "getProperty: environment is null, should never happen!");
+ } else {
+ value = environment.getRequiredProperty(key);
+ // java.util.Properties preserves trailing space
+ if (value != null)
+ value = value.trim();
+ }
+ return value;
+ }*/
+
}
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAccessRolesController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAccessRolesController.java
index e0bf7b01..4a5e0331 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAccessRolesController.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAccessRolesController.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -854,7 +854,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl
@RequestMapping(value = { "/v2/user/{loginId}" }, method = RequestMethod.GET, produces = "application/json")
public String getEcompUser(HttpServletRequest request, HttpServletResponse response,
@PathVariable("loginId") String loginId) throws Exception {
- EcompUser user = null;
+ EcompUser user = new EcompUser();
ObjectMapper mapper = new ObjectMapper();
String answer = null;
try {
@@ -868,10 +868,7 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl
sendErrorResponse(response, e);
logger.error(EELFLoggerDelegate.errorLogger, "getEcompUser failed", e);
}
- if (user != null) {
- return mapper.writeValueAsString(user);
- }
- return null;
+ return mapper.writeValueAsString(user);
}
@ApiOperation(value = "Gets user ecomp role for an application.", response = CentralUser.class, responseContainer = "List")
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WebAnalyticsExtAppController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WebAnalyticsExtAppController.java
index 7c53d62c..afde8bc5 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WebAnalyticsExtAppController.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WebAnalyticsExtAppController.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -219,7 +219,7 @@ public class WebAnalyticsExtAppController extends EPRestrictedRESTfulBaseControl
if (appKeyValue == null || appKeyValue.equals("")) {
logger.error(EELFLoggerDelegate.errorLogger, " App Key unavailable; Proceeding with null app name");
} else {
- EPApp appRecord = appCacheService.getAppForAnalytics(appKeyValue);
+ EPApp appRecord = appCacheService.getAppFromUeb(appKeyValue);
if (appRecord == null) {
logger.error(EELFLoggerDelegate.errorLogger, " App could not be found for the key " + appKeyValue);
} else
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/ecomp/model/AppContactUsItem.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/ecomp/model/AppContactUsItem.java
index 9e1c3b3b..c7c8ebcc 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/ecomp/model/AppContactUsItem.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/ecomp/model/AppContactUsItem.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/interceptor/PortalResourceInterceptor.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/interceptor/PortalResourceInterceptor.java
index 25ca5e65..3160032f 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/interceptor/PortalResourceInterceptor.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/interceptor/PortalResourceInterceptor.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -61,8 +61,10 @@ import org.onap.portalapp.portal.domain.EPUser;
import org.onap.portalapp.portal.logging.aop.EPEELFLoggerAdvice;
import org.onap.portalapp.portal.logging.format.EPAppMessagesEnum;
import org.onap.portalapp.portal.logging.logic.EPLogUtil;
+import org.onap.portalapp.portal.service.AppsCacheService;
import org.onap.portalapp.portal.service.BasicAuthenticationCredentialService;
import org.onap.portalapp.portal.service.ExternalAccessRolesService;
+import org.onap.portalapp.portal.utils.EPCommonSystemProperties;
import org.onap.portalapp.portal.utils.EcompPortalUtils;
import org.onap.portalapp.service.RemoteWebServiceCallService;
import org.onap.portalapp.service.sessionmgt.ManageService;
@@ -79,8 +81,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.method.HandlerMethod;
public class PortalResourceInterceptor extends ResourceInterceptor {
- private static final String APP_KEY = "uebkey";
-
+
private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PortalResourceInterceptor.class);
@Autowired
@@ -88,6 +89,9 @@ public class PortalResourceInterceptor extends ResourceInterceptor {
@Autowired
private ManageService manageService;
+
+ @Autowired
+ AppsCacheService appCacheService;
@Autowired
private EPEELFLoggerAdvice epAdvice;
@@ -167,7 +171,7 @@ public class PortalResourceInterceptor extends ResourceInterceptor {
String secretKey = null;
try {
epAdvice.loadServletRequestBasedDefaults(request, SecurityEventTypeEnum.INCOMING_REST_MESSAGE);
- if (!remoteWebServiceCallService.verifyRESTCredential(secretKey, request.getHeader(APP_KEY),
+ if (!remoteWebServiceCallService.verifyRESTCredential(secretKey, request.getHeader(EPCommonSystemProperties.UEB_KEY),
request.getHeader("username"), request.getHeader("password"))) {
throw new UrlAccessRestrictedException();
}
@@ -180,7 +184,7 @@ public class PortalResourceInterceptor extends ResourceInterceptor {
}
if (controllerObj instanceof WebAnalyticsExtAppController) {
- if (!remoteWebServiceCallService.verifyAppKeyCredential(request.getHeader(APP_KEY))) {
+ if (!remoteWebServiceCallService.verifyAppKeyCredential(request.getHeader(EPCommonSystemProperties.UEB_KEY))) {
logger.error(EELFLoggerDelegate.errorLogger,
"preHandle: failed to verify app key for web analytics call");
throw new UrlAccessRestrictedException();
@@ -226,8 +230,8 @@ public class PortalResourceInterceptor extends ResourceInterceptor {
String uri = request.getRequestURI().toString();
uri = uri.substring(uri.indexOf("/", 1));
- final String authHeader = request.getHeader("Authorization");
- final String uebkey = request.getHeader("uebkey");
+ final String authHeader = request.getHeader(EPCommonSystemProperties.AUTHORIZATION);
+ final String uebkey = request.getHeader(EPCommonSystemProperties.UEB_KEY);
// Unauthorized access due to missing HTTP Authorization request header
if (authHeader == null) {
@@ -237,7 +241,7 @@ public class PortalResourceInterceptor extends ResourceInterceptor {
return false;
}
- String[] accountNamePassword = getUserNamePassword(authHeader);
+ String[] accountNamePassword = EcompPortalUtils.getUserNamePassword(authHeader);
if (accountNamePassword == null || accountNamePassword.length != 2) {
final String msg = "failed to get username and password from Atuhorization header";
logger.debug(EELFLoggerDelegate.debugLogger, "checkBasicAuth: {}", msg);
@@ -247,15 +251,11 @@ public class PortalResourceInterceptor extends ResourceInterceptor {
if(uebkey !=null && !uebkey.isEmpty())
{
- List<EPApp> app = externalAccessRolesService.getApp(uebkey);
- EPApp application = null;
- if (app.isEmpty()) {
+ EPApp application = appCacheService.getAppFromUeb(uebkey,1);
+ if (application == null) {
throw new Exception("Invalid uebkey!");
}
- if (app.size() != 0 && !app.isEmpty()) {
- application = app.get(0);
- }
- if (application != null) {
+ else {
final String appUsername = application.getUsername();
final String dbDecryptedPwd = CipherUtil.decryptPKC(application.getAppPassword());
if (appUsername.equals(accountNamePassword[0]) && dbDecryptedPwd.equals(accountNamePassword[1])) {
@@ -317,13 +317,6 @@ public class PortalResourceInterceptor extends ResourceInterceptor {
return true;
}
- private String[] getUserNamePassword(String authValue) {
- String base64Credentials = authValue.substring("Basic".length()).trim();
- String credentials = new String(Base64.getDecoder().decode(base64Credentials), Charset.forName("UTF-8"));
- final String[] values = credentials.split(":", 2);
- return values;
- }
-
@SuppressWarnings("unused")
private String decrypted(String encrypted) throws Exception {
String result = "";
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/listener/HealthMonitor.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/listener/HealthMonitor.java
index 82f5637d..6df4f9bd 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/listener/HealthMonitor.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/listener/HealthMonitor.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -405,7 +405,6 @@ public class HealthMonitor {
pQuery.addValue(creationTime.toString());
pQuery.addValue(APPLICATION);
try {
- MusicCore.nonKeyRelatedPut(pQuery, MusicUtil.ATOMIC);
MusicCore.nonKeyRelatedPut(pQuery, MusicUtil.CRITICAL);
} catch (MusicServiceException e) {
return Boolean.FALSE;
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/aop/EPEELFLoggerAdvice.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/aop/EPEELFLoggerAdvice.java
index 18fb5027..71338a84 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/aop/EPEELFLoggerAdvice.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/aop/EPEELFLoggerAdvice.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -38,15 +38,17 @@
package org.onap.portalapp.portal.logging.aop;
import java.net.InetAddress;
-import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
+import org.onap.portalapp.portal.domain.EPApp;
import org.onap.portalapp.portal.domain.EPUser;
+import org.onap.portalapp.portal.service.AppsCacheService;
import org.onap.portalapp.portal.utils.EPCommonSystemProperties;
+import org.onap.portalapp.portal.utils.EcompPortalUtils;
import org.onap.portalapp.util.EPUserUtils;
import org.onap.portalsdk.core.exception.SessionExpiredException;
import org.onap.portalsdk.core.logging.format.AlarmSeverityEnum;
@@ -56,6 +58,7 @@ import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.portalsdk.core.util.SystemProperties.SecurityEventTypeEnum;
import org.onap.portalsdk.core.web.support.UserUtils;
import org.slf4j.MDC;
+import org.springframework.beans.factory.annotation.Autowired;
import com.att.eelf.configuration.Configuration;
@@ -63,6 +66,9 @@ import com.att.eelf.configuration.Configuration;
public class EPEELFLoggerAdvice {
private EELFLoggerDelegate adviceLogger = EELFLoggerDelegate.getLogger(EPEELFLoggerAdvice.class);
+
+ @Autowired
+ AppsCacheService appCacheService;
/**
* DateTime Format according to the ONAP Application Logging Guidelines.
@@ -166,7 +172,11 @@ public class EPEELFLoggerAdvice {
String requestId = UUID.randomUUID().toString();
MDC.put(Configuration.MDC_KEY_REQUEST_ID, requestId);
}
- MDC.put(EPCommonSystemProperties.PARTNER_NAME, "Unknown");
+
+ if (MDC.get(EPCommonSystemProperties.PARTNER_NAME) == null|| MDC.get(EPCommonSystemProperties.PARTNER_NAME).isEmpty()){
+ MDC.put(EPCommonSystemProperties.PARTNER_NAME, "Unknown");
+ }
+
MDC.put(Configuration.MDC_SERVICE_NAME, EPCommonSystemProperties.ECOMP_PORTAL_BE);
@@ -310,62 +320,18 @@ public class EPEELFLoggerAdvice {
&& securityEventType != SecurityEventTypeEnum.LDAP_PHONEBOOK_USER_SEARCH
&& securityEventType != SecurityEventTypeEnum.INCOMING_UEB_MESSAGE) {
// Load the RequestID (aka TrasactionId) into MDC context.
- String requestId = UserUtils.getRequestId(req);
- if (requestId == null||requestId.trim().length()==0) {
- requestId = UUID.randomUUID().toString();
- }
- MDC.put(Configuration.MDC_KEY_REQUEST_ID, requestId);
-
- // Load user agent into MDC context, if available.
- String accessingClient = req.getHeader(SystemProperties.USERAGENT_NAME);
- accessingClient = (accessingClient == null || accessingClient.trim().length()==0)?"Unknown":accessingClient;
- if (accessingClient != null && accessingClient.trim().length()==0 && (accessingClient.contains("Mozilla")
- || accessingClient.contains("Chrome") || accessingClient.contains("Safari"))) {
- accessingClient = EPCommonSystemProperties.ECOMP_PORTAL_FE;
- }
- MDC.put(EPCommonSystemProperties.PARTNER_NAME, accessingClient);
-
- // Load loginId into MDC context.
- EPUser user = null;
- try {
- user = EPUserUtils.getUserSession(req);
- } catch (SessionExpiredException se) {
- adviceLogger.debug(EELFLoggerDelegate.debugLogger,
- "setHttpRequestBasedDefaultsIntoGlobalLoggingContext: No user found in session");
- }
+ loadRequestId(req);
+
+ loadPartnerName(req);
- MDC.put(EPCommonSystemProperties.MDC_LOGIN_ID, (user != null ? user.getOrgUserId() : "NoUser"));
-
- // Rest URL & Protocol
- String restURL = "";
- MDC.put(EPCommonSystemProperties.FULL_URL, EPCommonSystemProperties.UNKNOWN);
- MDC.put(EPCommonSystemProperties.PROTOCOL, EPCommonSystemProperties.HTTP);
- restURL = UserUtils.getFullURL(req);
- //if (restURL != null && restURL != "") {
- if (restURL != null && restURL.trim().length()>0) {
- MDC.put(EPCommonSystemProperties.FULL_URL, restURL);
- if (restURL.toLowerCase().contains("https")) {
- MDC.put(EPCommonSystemProperties.PROTOCOL, EPCommonSystemProperties.HTTPS);
- }
- }
+ loadLoginId(req);
- // Rest Path
- MDC.put(Configuration.MDC_SERVICE_NAME, restMethod);
- String restPath = req.getServletPath();
- //if (restPath != null && restPath != "") {
- if (restPath != null && restPath.trim().length()>0) {
+ loadUrlProtocol(req);
- MDC.put(Configuration.MDC_SERVICE_NAME, restPath);
- }
+ loadServicePath(req, restMethod);
- // Client IPAddress i.e. IPAddress of the remote host who is
- // making this request.
- String clientIPAddress = "";
- clientIPAddress = req.getHeader("X-FORWARDED-FOR");
- if (clientIPAddress == null) {
- clientIPAddress = req.getRemoteAddr();
- }
- MDC.put(EPCommonSystemProperties.CLIENT_IP_ADDRESS, clientIPAddress);
+ loadClientAddress(req);
+
} else if (securityEventType == SecurityEventTypeEnum.LDAP_PHONEBOOK_USER_SEARCH) {
MDC.put(EPCommonSystemProperties.TARGET_ENTITY, "Phonebook");
MDC.put(EPCommonSystemProperties.TARGET_SERVICE_NAME, "search");
@@ -387,6 +353,105 @@ public class EPEELFLoggerAdvice {
}
}
+ private void loadClientAddress(HttpServletRequest req) {
+ // Client IPAddress i.e. IPAddress of the remote host who is
+ // making this request.
+ String clientIPAddress = "";
+ clientIPAddress = req.getHeader("X-FORWARDED-FOR");
+ if (clientIPAddress == null) {
+ clientIPAddress = req.getRemoteAddr();
+ }
+ MDC.put(EPCommonSystemProperties.CLIENT_IP_ADDRESS, clientIPAddress);
+ }
+
+ private void loadServicePath(HttpServletRequest req, String restMethod) {
+ // Rest Path
+ MDC.put(Configuration.MDC_SERVICE_NAME, restMethod);
+ String restPath = req.getServletPath();
+ //if (restPath != null && restPath != "") {
+ if (restPath != null && restPath.trim().length()>0) {
+
+ MDC.put(Configuration.MDC_SERVICE_NAME, restPath);
+ }
+ }
+
+ private void loadUrlProtocol(HttpServletRequest req) {
+ // Rest URL & Protocol
+ String restURL = "";
+ MDC.put(EPCommonSystemProperties.FULL_URL, EPCommonSystemProperties.UNKNOWN);
+ MDC.put(EPCommonSystemProperties.PROTOCOL, EPCommonSystemProperties.HTTP);
+ restURL = UserUtils.getFullURL(req);
+ //if (restURL != null && restURL != "") {
+ if (restURL != null && restURL.trim().length()>0) {
+ MDC.put(EPCommonSystemProperties.FULL_URL, restURL);
+ if (restURL.toLowerCase().contains("https")) {
+ MDC.put(EPCommonSystemProperties.PROTOCOL, EPCommonSystemProperties.HTTPS);
+ }
+ }
+ }
+
+ private void loadRequestId(HttpServletRequest req) {
+ String requestId = UserUtils.getRequestId(req);
+ if (requestId == null||requestId.trim().length()==0) {
+ requestId = UUID.randomUUID().toString();
+ }
+ MDC.put(Configuration.MDC_KEY_REQUEST_ID, requestId);
+ }
+
+ private void loadLoginId(HttpServletRequest req) {
+ // Load loginId into MDC context.
+ String loginId = "NoUser";
+
+ try {
+ EPUser user = EPUserUtils.getUserSession(req);
+ loginId = (user != null ? user.getOrgUserId(): loginId);
+ } catch (SessionExpiredException se) {
+ adviceLogger.debug(EELFLoggerDelegate.debugLogger,
+ "setHttpRequestBasedDefaultsIntoGlobalLoggingContext: No user found in session");
+ }
+
+ // try fetching from username in header
+ final String nameHeader = req.getHeader(EPCommonSystemProperties.USERNAME);
+ if (nameHeader != null) {
+ loginId = nameHeader;
+ }
+
+ // try fetching from BasicAuth info
+ final String authHeader = req.getHeader(EPCommonSystemProperties.AUTHORIZATION);
+ if (authHeader != null) {
+ String[] accountNamePassword = EcompPortalUtils.getUserNamePassword(authHeader);
+ if (accountNamePassword != null && accountNamePassword.length == 2) {
+ loginId = accountNamePassword[0];
+ }
+
+ }
+
+ MDC.put(EPCommonSystemProperties.MDC_LOGIN_ID, loginId );
+
+ }
+
+ private void loadPartnerName(HttpServletRequest req) {
+
+
+ // Load user agent into MDC context, if available.
+ String accessingClient = req.getHeader(SystemProperties.USERAGENT_NAME);
+ accessingClient = (accessingClient == null || accessingClient.trim().length()==0)?"Unknown":accessingClient;
+ if (accessingClient != null && accessingClient.trim().length()==0 && (accessingClient.contains("Mozilla")
+ || accessingClient.contains("Chrome") || accessingClient.contains("Safari"))) {
+ accessingClient = EPCommonSystemProperties.ECOMP_PORTAL_FE;
+ }
+ MDC.put(EPCommonSystemProperties.PARTNER_NAME, accessingClient);
+
+ // try get the Partner name from uebkey
+ String uebVal = req.getHeader(EPCommonSystemProperties.UEB_KEY);
+ if(uebVal != null) {
+ EPApp appRecord = appCacheService.getAppFromUeb(uebVal);
+ MDC.put(EPCommonSystemProperties.PARTNER_NAME, appRecord.getName());
+ }
+
+
+ }
+
/**
*
* @param beginDateTime
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/logic/AuxDiscriminator.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/logic/AuxDiscriminator.java
new file mode 100644
index 00000000..d3add13d
--- /dev/null
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/logic/AuxDiscriminator.java
@@ -0,0 +1,74 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalapp.portal.logging.logic;
+
+import java.util.Map;
+
+import org.onap.portalsdk.core.util.SystemProperties;
+
+import ch.qos.logback.classic.sift.MDCBasedDiscriminator;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+
+public class AuxDiscriminator extends MDCBasedDiscriminator {
+
+ final String MUSIC = "music";
+ final String HEALTHMONITOR = "HealthMonitor";
+
+ @Override
+ public String getDiscriminatingValue(ILoggingEvent event) {
+
+ String message = event.getMessage();
+ if (message != null && message.matches("org.onap.music.*")) {
+ return getDefaultValue() + "-" + MUSIC;
+ }
+
+ Map<String, String> mdcMap = event.getMDCPropertyMap();
+ if (mdcMap == null) {
+ return getDefaultValue();
+ }
+ String mdcValue = mdcMap.get(SystemProperties.MDC_CLASS_NAME);
+ if (mdcValue != null && mdcValue.endsWith(HEALTHMONITOR)) {
+ return getDefaultValue() + "-" + HEALTHMONITOR;
+ }
+
+
+ return getDefaultValue();
+ }
+
+
+}
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxUtil.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxUtil.java
index 763505b3..4e470462 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxUtil.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxUtil.java
@@ -82,24 +82,5 @@ public class SchedulerAuxUtil {
return (w);
}
- public static <T> String convertPojoToString ( T t ) throws com.fasterxml.jackson.core.JsonProcessingException {
-
- String methodName = "convertPojoToString";
- ObjectMapper mapper = new ObjectMapper();
- String r_json_str = "";
- if ( t != null ) {
- try {
- r_json_str = mapper.writeValueAsString(t);
- }
- catch ( com.fasterxml.jackson.core.JsonProcessingException j ) {
- logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " Unable to parse object as json");
- }
- }
- return (r_json_str);
- }
-
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- }
}
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ApplicationsRestClientServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ApplicationsRestClientServiceImpl.java
index c9f2c6ee..5a354f3a 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ApplicationsRestClientServiceImpl.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ApplicationsRestClientServiceImpl.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -358,48 +358,6 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient
return post( clazz, appId, payload, restPath, SystemType.APPLICATION);
}
- //@Override
- public <T> T postForClass(Class<T> clazz, long appId, Object payload, String restPath, Class<T> forClass) throws HTTPException {
- WebClient client = null;
- Response response = null;
- T t = null;
- logger.debug(EELFLoggerDelegate.debugLogger, "Entering to createClientForApp method for payload: {} and restPath: {} and appId: {}", payload.toString(), restPath, appId);
- client = createClientForApp(appId, restPath);
- EcompPortalUtils.logAndSerializeObject(logger, restPath, "POST request =", payload);
- logger.debug(EELFLoggerDelegate.debugLogger, "Finished createClientForApp method for payload: {} and restPath: {} and appId: {}", payload.toString(), restPath, appId);
- try {
- if (client != null) {
- logger.debug(EELFLoggerDelegate.debugLogger, "Entering to POST for payload: {} and restPath: {} and appId: {}", payload.toString(), restPath, appId);
- response = client.post(payload);
- logger.debug(EELFLoggerDelegate.debugLogger, "Finished to POST for payload: {} and restPath: {} and appId: {}", payload.toString(), restPath, appId);
- } else {
- logger.error(EELFLoggerDelegate.errorLogger,
- "Unable to create the Webclient to make the '" + restPath + "' API call.");
- }
- } catch (Exception e) {
- MDC.put(EPCommonSystemProperties.EXTERNAL_API_RESPONSE_CODE,
- Integer.toString(HttpServletResponse.SC_INTERNAL_SERVER_ERROR));
- EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeRestApiGeneralError, e);
- logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while making the POST REST API call", e);
- }
-
- if (response != null) {
- verifyResponse(response);
-
- // String contentType = response.getHeaderString("Content-Type");
- if (clazz != null) {
- String str = ((ResponseImpl)response).readEntity(String.class);
- EcompPortalUtils.logAndSerializeObject(logger, restPath, "POST result =", str);
- try {
- t = gson.fromJson(str, clazz);
- } catch (Exception e) {
- EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeInvalidJsonInput, e);
- }
- }
- }
- return t;
- }
-
@Override
public <T> T put(Class<T> clazz, long appId, Object payload, String restPath) throws HTTPException {
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AppsCacheService.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AppsCacheService.java
index 2aaf30df..b684d3f1 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AppsCacheService.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AppsCacheService.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -56,5 +56,7 @@ public interface AppsCacheService {
*/
String getAppEndpoint(Long appId);
- EPApp getAppForAnalytics(String appKey);
+ EPApp getAppFromUeb(String appKey);
+
+ EPApp getAppFromUeb(String appKey, Integer quickCacheRefresh);
}
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AppsCacheServiceImple.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AppsCacheServiceImple.java
index 06adb7f5..0fb92900 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AppsCacheServiceImple.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AppsCacheServiceImple.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -73,47 +73,46 @@ public class AppsCacheServiceImple implements AppsCacheService {
}
}
- CacheConfiguration appConf = null;
- CacheConfiguration analyticsAppConf = null;
+ CacheConfiguration quickRefreshCacheConf = null;
+ CacheConfiguration slowRefreshCacheConf = null;
private static volatile Map<Long, EPApp> appsMap;
- private static volatile Map<String, EPApp> anlyticsAppsMap;
+ private static volatile Map<String, EPApp> uebAppsMap;
@PostConstruct
public void init() {
- appConf = new CacheConfiguration(0, 10);
- analyticsAppConf = new CacheConfiguration(0, 3600);
+ quickRefreshCacheConf = new CacheConfiguration(0, 120);
+ slowRefreshCacheConf = new CacheConfiguration(0, 3600);
- this.refreshAppsMap(appConf);
+ this.refreshAppsMap(quickRefreshCacheConf);
}
- private Map<Long, EPApp> refreshAppsMap(CacheConfiguration conf) {
+ private void refreshAppsMap(CacheConfiguration conf) {
long now = System.currentTimeMillis();
if(noNeedToUpdate(now, conf))
- return null;
+ return;
synchronized (this) {
if(noNeedToUpdate(now, conf))
- return null;
+ return;
List<EPApp> allApps = appsService.getAppsFullList();
Map<Long, EPApp> newAppsMap = new HashMap<Long, EPApp>();
for (EPApp app : allApps) {
newAppsMap.put(app.getId(), app);
}
- Map<String, EPApp> newAnalyticsAppsMap = new HashMap<String, EPApp>();
+ Map<String, EPApp> newUebAppsMap = new HashMap<String, EPApp>();
for (EPApp app : allApps) {
- newAnalyticsAppsMap.put(app.getUebKey(), app);
+ newUebAppsMap.put(app.getUebKey(), app);
}
// Switch cache with the new one.
appsMap = newAppsMap;
- anlyticsAppsMap = newAnalyticsAppsMap;
+ uebAppsMap = newUebAppsMap;
conf.updateTime = now;
}
- return appsMap;
}
private boolean noNeedToUpdate(long now, CacheConfiguration conf) {
@@ -127,7 +126,7 @@ public class AppsCacheServiceImple implements AppsCacheService {
@Override
public String getAppEndpoint(Long appId) {
- refreshAppsMap(appConf);
+ refreshAppsMap(quickRefreshCacheConf);
EPApp app = appsMap.get(appId);
if(app != null)
return app.getAppRestEndpoint();
@@ -136,7 +135,7 @@ public class AppsCacheServiceImple implements AppsCacheService {
@Override
public EPApp getApp(Long appId) {
- refreshAppsMap(appConf);
+ refreshAppsMap(quickRefreshCacheConf);
EPApp app = appsMap.get(appId);
if(app != null)
return app;
@@ -144,9 +143,14 @@ public class AppsCacheServiceImple implements AppsCacheService {
}
@Override
- public EPApp getAppForAnalytics(String appKey) {
- refreshAppsMap(analyticsAppConf);
- EPApp app = anlyticsAppsMap.get(appKey);
+ public EPApp getAppFromUeb(String appKey) {
+ return getAppFromUeb(appKey,0);
+ }
+
+ @Override
+ public EPApp getAppFromUeb(String appKey, Integer quickCacheRefresh) {
+ refreshAppsMap(quickCacheRefresh == 1 ? quickRefreshCacheConf:slowRefreshCacheConf);
+ EPApp app = uebAppsMap.get(appKey);
if(app != null)
return app;
return null;
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPRoleFunctionServiceCentralizedImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPRoleFunctionServiceCentralizedImpl.java
index a64aea47..3693906b 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPRoleFunctionServiceCentralizedImpl.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPRoleFunctionServiceCentralizedImpl.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -43,18 +43,13 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
-import org.apache.commons.codec.DecoderException;
-import org.apache.commons.codec.binary.Hex;
import org.hibernate.SessionFactory;
-import org.onap.portalapp.portal.controller.RoleManageController;
import org.onap.portalapp.portal.domain.CentralV2RoleFunction;
-import org.onap.portalapp.portal.domain.EPRole;
import org.onap.portalapp.portal.domain.EPUser;
import org.onap.portalapp.portal.exceptions.RoleFunctionException;
import org.onap.portalapp.portal.utils.EcompPortalUtils;
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImpl.java
index 1811f8dc..e3ce07ff 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImpl.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImpl.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -482,6 +482,7 @@ public class UserRolesCommonServiceImpl {
oldAppRole.setName(role.getName());
localSession.update(oldAppRole);
}
+ oldAppRole.setActive(true);
newRolesMap.remove(oldAppRole.getAppRoleId());
} else {
obsoleteRoles.add(oldAppRole);
@@ -817,16 +818,7 @@ public class UserRolesCommonServiceImpl {
private EPUser addRemoteUser(List<RoleInAppForUser> roleInAppForUserList, String userId, EPApp app, ObjectMapper mapper, SearchService searchService, ApplicationsRestClientService applicationsRestClientService) throws Exception{
EPUser addRemoteUser = null;
if (remoteUserShouldBeCreated(roleInAppForUserList)) {
-
createNewUserOnRemoteApp(userId, app, applicationsRestClientService, searchService, mapper, isAppUpgradeVersion(app));
- // If we succeed, we know that the new user was
- // persisted on remote app.
- addRemoteUser = getUserFromApp(userId, app, applicationsRestClientService);
- if (addRemoteUser == null) {
- logger.error(EELFLoggerDelegate.errorLogger,
- "Failed to persist new user: " + userId + " in remote app. appId = " + app.getId());
- // return null;
- }
}
return addRemoteUser;
}
@@ -890,14 +882,12 @@ public class UserRolesCommonServiceImpl {
// if centralized app
if (app.getCentralAuth()) {
- // We should add If user does not exist in remote application
if (!app.getId().equals(PortalConstants.PORTAL_APP_ID)) {
- EPUser remoteAppUser = null;
- remoteAppUser = checkIfRemoteUserExits(userId, app, applicationsRestClientService);
-
- if (remoteAppUser == null) {
+ try {
addRemoteUser(roleInAppForUserList, userId, app, mapper, searchService,
applicationsRestClientService);
+ } catch (Exception e) {
+ logger.debug(EELFLoggerDelegate.debugLogger, e.getMessage());
}
}
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserServiceImpl.java
index 755de799..0f91f620 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserServiceImpl.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserServiceImpl.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -130,7 +130,9 @@ public class UserServiceImpl implements UserService {
logger.error(EELFLoggerDelegate.errorLogger, "getUserByUserId failed", e);
} finally {
try {
+ if(in!=null) {
in.close();
+ }
con.disconnect();
} catch (IOException e) {
logger.error(EELFLoggerDelegate.errorLogger, "getUserByUserId failed to close", e);
@@ -187,8 +189,9 @@ public class UserServiceImpl implements UserService {
in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
String inputLine;
- while ((inputLine = in.readLine()) != null)
+ while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
+ }
JSONObject jObject = new JSONObject(response.toString()); // json
JSONArray jsonUsers = jObject.getJSONArray("response"); // get
// data
@@ -224,8 +227,10 @@ public class UserServiceImpl implements UserService {
logger.error(EELFLoggerDelegate.errorLogger, "getUserByFirstLastName failed", e);
} finally {
try {
+ if(in!=null) {
in.close();
con.disconnect();
+ }
} catch (IOException e) {
logger.error(EELFLoggerDelegate.errorLogger, "getUserByFirstLastName failed to close", e);
}
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/EpNotificationItemVO.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/EpNotificationItemVO.java
index 9cb7c755..6f927b38 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/EpNotificationItemVO.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/EpNotificationItemVO.java
@@ -197,10 +197,6 @@ public class EpNotificationItemVO extends DomainVo {
this.createdDate = createdDate;
}
- public static long getSerialversionuid() {
- return serialVersionUID;
- }
-
public String getMsgSource() {
return msgSource;
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/RemoteRoleV1.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/RemoteRoleV1.java
index 724c275d..9abac530 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/RemoteRoleV1.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/RemoteRoleV1.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -33,7 +33,7 @@
*
* ============LICENSE_END============================================
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
*/
package org.onap.portalapp.portal.transport;
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EPCommonSystemProperties.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EPCommonSystemProperties.java
index 53f6a3ee..2c619af8 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EPCommonSystemProperties.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EPCommonSystemProperties.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -96,5 +96,8 @@ public class EPCommonSystemProperties extends SystemProperties {
public static final String MS_WIDGET_LOCAL_PORT = "microservices.widget.local.port";
public static final String MS_WIDGET_UPLOAD_FLAG = "microservices.widget.upload.flag";
-
+ public static final String UEB_KEY = "uebkey";
+ public static final String AUTHORIZATION = "Authorization";
+ public static final String USERNAME = "username";
+
}
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EcompPortalUtils.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EcompPortalUtils.java
index 53b69d7f..ab43149c 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EcompPortalUtils.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EcompPortalUtils.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -40,8 +40,10 @@ package org.onap.portalapp.portal.utils;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
+import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Base64;
import java.util.Date;
import java.util.List;
@@ -564,4 +566,18 @@ public class EcompPortalUtils {
return false;
}
}
+ /**
+ *
+ * It retrieves account information from input String
+ *
+ * @param authValue
+ * @return Array of Account information
+ *
+ */
+ public static String[] getUserNamePassword(String authValue) {
+ String base64Credentials = authValue.substring("Basic".length()).trim();
+ String credentials = new String(Base64.getDecoder().decode(base64Credentials), Charset.forName("UTF-8"));
+ final String[] values = credentials.split(":", 2);
+ return values;
+ }
}
diff --git a/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/EP.hbm.xml b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/EP.hbm.xml
index 34bd66af..becfe7c2 100644
--- a/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/EP.hbm.xml
+++ b/ecomp-portal-BE-common/src/main/webapp/WEB-INF/fusion/orm/EP.hbm.xml
@@ -3,7 +3,7 @@
============LICENSE_START==========================================
ONAP Portal
===================================================================
- Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
===================================================================
Unless otherwise specified, all software contained herein is licensed
@@ -40,7 +40,7 @@
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<!-- Publishes mappings and queries specific to the ECOMP Portal application. -->
+<!-- Publishes mappings and queries specific to the ONAP Portal application. -->
<hibernate-mapping package="org.onap.portalapp.portal.domain">
<!-- Widget class mapping details -->
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/music/util/MusicUtilTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/music/util/MusicUtilTest.java
index a570ab89..6c23515d 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/music/util/MusicUtilTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/music/util/MusicUtilTest.java
@@ -42,19 +42,23 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
+import java.io.StreamCorruptedException;
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+import java.time.Duration;
+import java.time.Instant;
import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.onap.portalapp.music.conf.MusicSession;
import org.onap.portalapp.music.service.MusicService;
-import org.onap.portalapp.music.util.MusicCleanUp;
-import org.onap.portalapp.music.util.MusicProperties;
-import org.onap.portalapp.music.util.MusicUtil;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@@ -69,6 +73,8 @@ public class MusicUtilTest {
ResultSet result = Mockito.mock(ResultSet.class);
Row rw = Mockito.mock(Row.class);
+ @Mock
+ ByteBuffer buffer;
@Before
public void setUp() throws Exception {
@@ -100,6 +106,46 @@ public class MusicUtilTest {
Mockito.doReturn(rows.get(0)).when(result).one();
assertNotNull(MusicUtil.musicRestResponseDataParsing(result, "CREATION_TIME"));
}
+
+ @Test(expected=StreamCorruptedException.class)
+ public void musicRestResponseDataParsingTestBytes() throws Exception {
+ List<Row> rows = new ArrayList<Row>();
+ //ByteBuffer byteBuffer = ByteBuffer.allocate(6);
+ ByteBuffer buff = Charset.forName("UTF-8").encode("Hello, World!");
+ Mockito.when(rw.getBytes("attribute_bytes")).thenReturn(buff);
+ rows.add(rw);
+ Mockito.doReturn(rows.get(0)).when(result).one();
+ assertNotNull(MusicUtil.musicRestResponseDataParsing(result, "TEST"));
+ }
+
+ @Test
+ public void testMusicSerialize()throws Exception {
+ String data="TEST";
+ MusicUtil.musicSerialize(data);
+
+
+ }
+ @Test
+ public void testParseMetaData()throws Exception {
+
+ Mockito.when(rw.getString("primary_id")).thenReturn("TestSession");
+ Mockito.when(rw.getString("creation_time")).thenReturn("2018-07-03T10:15:30.00Z");
+ Mockito.when(rw.getString("last_access_time")).thenReturn("2018-07-05T10:15:30.00Z");
+ Mockito.when(rw.getString("max_inactive_interval")).thenReturn("PT20.345S");
+ MusicSession session=MusicUtil.parseMetaData(rw);
+ assertNotNull(session);
+
+ }
+
+ @Test
+ public void testMusicSerializeMusicCompress()throws Exception {
+ PowerMockito.when(MusicProperties.getProperty(MusicProperties.MUSIC_SERIALIZE_COMPRESS)).thenReturn("true");
+ String data="TEST";
+ MusicUtil.musicSerialize(data);
+
+
+ }
+
@Test
public void getMusicExcludedAPITest() {
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/ExternalAccessRolesControllerTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/ExternalAccessRolesControllerTest.java
index 556e215c..f1d7c397 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/ExternalAccessRolesControllerTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/ExternalAccessRolesControllerTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -1086,7 +1086,7 @@ public class ExternalAccessRolesControllerTest {
Mockito.when(externalAccessRolesService.getApp(mockedRequest.getHeader(uebKey))).thenReturn(applicationList);
ResponseEntity<String> response = new ResponseEntity<>(HttpStatus.OK);
Mockito.when(externalAccessRolesService.getNameSpaceIfExists(app)).thenReturn(response);
- assertNull(externalAccessRolesController.getEcompUser(mockedRequest, mockedResponse, "test12"));
+ externalAccessRolesController.getEcompUser(mockedRequest, mockedResponse, "test12");
}
@Test
@@ -1117,7 +1117,7 @@ public class ExternalAccessRolesControllerTest {
StringWriter sw = new StringWriter();
PrintWriter writer = new PrintWriter(sw);
Mockito.when(mockedResponse.getWriter()).thenReturn(writer);
- assertNull(externalAccessRolesController.getEcompUser(mockedRequest, mockedResponse, "test12"));
+ externalAccessRolesController.getEcompUser(mockedRequest, mockedResponse, "test12");
}
@Test
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/UserNotificationControllerTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/UserNotificationControllerTest.java
index 047d60f3..bbb3ddbf 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/UserNotificationControllerTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/UserNotificationControllerTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -56,9 +56,9 @@ import org.mockito.Matchers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
-import org.onap.portalapp.portal.controller.UserNotificationController;
import org.onap.portalapp.portal.core.MockEPUser;
import org.onap.portalapp.portal.domain.EPUser;
+import org.onap.portalapp.portal.domain.EcompAppRole;
import org.onap.portalapp.portal.ecomp.model.PortalRestResponse;
import org.onap.portalapp.portal.ecomp.model.PortalRestStatusEnum;
import org.onap.portalapp.portal.framework.MockitoTestSuite;
@@ -68,6 +68,7 @@ import org.onap.portalapp.portal.service.UserNotificationService;
import org.onap.portalapp.portal.service.UserNotificationServiceImpl;
import org.onap.portalapp.portal.transport.EpNotificationItem;
import org.onap.portalapp.portal.transport.EpNotificationItemVO;
+import org.onap.portalapp.portal.transport.EpRoleNotificationItem;
import org.onap.portalapp.portal.transport.FunctionalMenuRole;
import org.onap.portalapp.util.EPUserUtils;
import org.onap.portalsdk.core.util.SystemProperties;
@@ -278,4 +279,56 @@ public class UserNotificationControllerTest {
assertTrue(actualPortalRestResponse.equals(expectedPortalRestResponse));
}
+ @Test
+ public void notificationRead() {
+ PowerMockito.mockStatic(UserUtils.class);
+ Mockito.when(UserUtils.getUserId(mockedRequest)).thenReturn(1);
+ userNotificationController.notificationRead("1", mockedRequest);
+ }
+
+ @Test
+ public void notificationRead_Error() {
+ PowerMockito.mockStatic(UserUtils.class);
+ Mockito.when(UserUtils.getUserId(mockedRequest)).thenReturn(1);
+ userNotificationController.notificationRead("Test", mockedRequest);
+ }
+
+ @Test
+ public void getNotificationHistory() {
+ PowerMockito.mockStatic(EPUserUtils.class);
+ EPUser user = mockUser.mockEPUser();
+ HttpSession session = mockedRequest.getSession();
+ session.setAttribute("user", user);
+ Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user);
+ userNotificationController.getNotificationHistory(mockedRequest, mockedResponse);
+ }
+
+ @Test
+ public void testGetRoles() {
+
+ List<EpRoleNotificationItem> NotifRoles =new ArrayList<>();
+ EpRoleNotificationItem epRole=new EpRoleNotificationItem();
+ epRole.setId(1l);
+
+ Mockito.when(userNotificationService.getNotificationRoles(1l)).thenReturn(NotifRoles);
+ userNotificationController.testGetRoles(mockedRequest, 1l);
+
+
+ }
+
+ @Test
+ public void getNotificationAppRoles() {
+ List<EcompAppRole> epAppRoleList =new ArrayList<>();
+ Mockito.when(userNotificationService.getAppRoleList()).thenReturn(epAppRoleList);
+ userNotificationController.getNotificationAppRoles(mockedRequest, mockedResponse);
+ }
+
+
+ @Test
+ public void getMessageRecipients() {
+
+ Mockito.when(userNotificationService.getMessageRecipients(1l)).thenReturn(new ArrayList<>());
+ userNotificationController.getMessageRecipients(1l);
+ }
+
}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/UserRolesControllerTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/UserRolesControllerTest.java
index 04c3a26c..056653b8 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/UserRolesControllerTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/UserRolesControllerTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -61,6 +61,7 @@ import org.onap.portalapp.portal.framework.MockitoTestSuite;
import org.onap.portalapp.portal.service.AdminRolesService;
import org.onap.portalapp.portal.service.SearchService;
import org.onap.portalapp.portal.service.UserRolesService;
+import org.onap.portalapp.portal.transport.AppNameIdIsAdmin;
import org.onap.portalapp.portal.transport.AppWithRolesForUser;
import org.onap.portalapp.portal.transport.AppsListWithAdminRole;
import org.onap.portalapp.portal.transport.FieldsValidator;
@@ -166,6 +167,132 @@ public class UserRolesControllerTest extends MockitoTestSuite {
assertEquals(expectedFieldValidator.getFields(), actualFieldsValidator.getFields());
}
+ @Test
+ public void testPutAppWithUserRoleStateForUser() {
+ AppWithRolesForUser appWithRolesForUser =buildAppwithRoles();
+ EPUser user = mockUser.mockEPUser();
+ Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user);
+ Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(false);
+ Mockito.when(adminRolesService.isAccountAdmin(user)).thenReturn(true);
+ Mockito.when(userRolesService.setAppWithUserRoleStateForUser(user, appWithRolesForUser)).thenReturn(true);
+ userRolesController.putAppWithUserRoleStateForUser(mockedRequest, appWithRolesForUser, mockedResponse);
+
+ }
+
+ @Test
+ public void testPutAppWithUserRoleStateForSuperAdminUser() {
+ AppsListWithAdminRole adminRoleUser=buildAdminRoleUser();
+
+ EPUser user = mockUser.mockEPUser();
+ Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user);
+ Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(true);
+ Mockito.when(adminRolesService.isAccountAdmin(user)).thenReturn(true);
+ Mockito.when(adminRolesService.setAppsWithAdminRoleStateForUser( adminRoleUser)).thenReturn(true);
+ userRolesController.putAppsWithAdminRoleStateForUser(mockedRequest, adminRoleUser, mockedResponse);
+
+ }
+
+
+
+ @Test
+ public void testPutAppWithUserRoleStateForAdminUser() {
+ AppsListWithAdminRole adminRoleUser=buildAdminRoleUser();
+
+ EPUser user = mockUser.mockEPUser();
+ Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user);
+ Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(false);
+ Mockito.when(adminRolesService.isAccountAdmin(user)).thenReturn(true);
+ Mockito.when(adminRolesService.setAppsWithAdminRoleStateForUser( adminRoleUser)).thenReturn(true);
+ userRolesController.putAppsWithAdminRoleStateForUser(mockedRequest, adminRoleUser, mockedResponse);
+
+ }
+ @Test
+ public void testPutAppWithUserRoleStateForStandardUser() {
+ AppWithRolesForUser appWithRolesForUser =buildAppwithRoles();
+ EPUser user = mockUser.mockEPUser();
+ Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user);
+ Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(false);
+ Mockito.when(adminRolesService.isAccountAdmin(user)).thenReturn(false);
+ userRolesController.putAppWithUserRoleStateForUser(mockedRequest, appWithRolesForUser, mockedResponse);
+
+ }
+
+ @Test
+ public void testPutAppWithUserRoleRequest() {
+ AppWithRolesForUser appWithRolesForUser =buildAppwithRoles();
+ EPUser user = mockUser.mockEPUser();
+ Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user);
+ FieldsValidator fieldsValidator=new FieldsValidator();
+ fieldsValidator.setHttpStatusCode(200l);
+ Mockito.when(userRolesService.putUserAppRolesRequest(appWithRolesForUser, user)).thenReturn(fieldsValidator);
+ userRolesController.putAppWithUserRoleRequest(mockedRequest, appWithRolesForUser, mockedResponse);
+
+ }
+
+ @Test
+ public void testPutAppWithUserRoleBadRequest() {
+ AppWithRolesForUser appWithRolesForUser =buildAppwithRoles();
+ EPUser user = mockUser.mockEPUser();
+ Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user);
+ userRolesController.putAppWithUserRoleRequest(mockedRequest, appWithRolesForUser, mockedResponse);
+
+ }
+
+ private AppsListWithAdminRole buildAdminRoleUser() {
+ AppsListWithAdminRole adminRoleUser=new AppsListWithAdminRole();
+ ArrayList<AppNameIdIsAdmin> roles=new ArrayList<>();
+
+ AppNameIdIsAdmin adminAppRole=new AppNameIdIsAdmin();
+ adminAppRole.setAppName("test");
+ adminAppRole.setIsAdmin(true);
+ adminAppRole.setRestrictedApp(false);
+
+
+ AppNameIdIsAdmin adminAppRole1=new AppNameIdIsAdmin();
+ adminAppRole1.setAppName("Sample");
+ adminAppRole1.setIsAdmin(true);
+ adminAppRole1.setRestrictedApp(true);
+
+
+ AppNameIdIsAdmin adminAppRole2=new AppNameIdIsAdmin();
+ adminAppRole2.setAppName("testSample");
+ adminAppRole2.setIsAdmin(false);
+ adminAppRole2.setRestrictedApp(true);
+ roles.add(adminAppRole);
+ roles.add(adminAppRole1);
+ roles.add(adminAppRole2);
+ adminRoleUser.setAppsRoles(roles);
+
+
+ return adminRoleUser;
+
+
+ }
+
+ private AppWithRolesForUser buildAppwithRoles() {
+ AppWithRolesForUser appWithRolesForUser = new AppWithRolesForUser();
+ List<RoleInAppForUser> listofRoles = new ArrayList<RoleInAppForUser>();
+
+ appWithRolesForUser.setOrgUserId("guest");
+ appWithRolesForUser.setAppId((long) 550);
+ appWithRolesForUser.setAppName("D2 Services Analytics Dashboard");
+ appWithRolesForUser.setAppRoles(listofRoles);
+
+ RoleInAppForUser roleInAppForUser = new RoleInAppForUser();
+ roleInAppForUser.setIsApplied(false);
+ roleInAppForUser.setRoleId((long) 1);
+ roleInAppForUser.setRoleName("System Administrator");
+
+ RoleInAppForUser roleInAppForUser1 = new RoleInAppForUser();
+ roleInAppForUser1.setIsApplied(true);
+ roleInAppForUser1.setRoleId((long) 16);
+ roleInAppForUser1.setRoleName("Standard User");
+
+ listofRoles.add(roleInAppForUser);
+ listofRoles.add(roleInAppForUser1);
+ appWithRolesForUser.setAppRoles(listofRoles);
+ return appWithRolesForUser;
+ }
@Test
public void getPhoneBookSearchResultBadPermissionsTest() {
@@ -199,7 +326,7 @@ public class UserRolesControllerTest extends MockitoTestSuite {
actualResult = userRolesController.getPhoneBookSearchResult(mockedRequest, searchString, mockedResponse);
assertEquals(expectedResult, actualResult);
- }
+ }
@Test
public void getPhoneBookSearchResultTest() {
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WebAnalyticsExtAppControllerTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WebAnalyticsExtAppControllerTest.java
index c59036f5..e5ee9d92 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WebAnalyticsExtAppControllerTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WebAnalyticsExtAppControllerTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -87,6 +87,9 @@ public class WebAnalyticsExtAppControllerTest {
@Mock
AuditService auditService = new AuditServiceImpl();
+ @Mock
+ Analytics analytics;
+
// @Mock
// InputStream analyticsFileStream;
@@ -143,5 +146,29 @@ public class WebAnalyticsExtAppControllerTest {
assertTrue(expectedPortalAPIResponse.getMessage().equals(actualPortalAPIResponse.getMessage()));
assertTrue(expectedPortalAPIResponse.getStatus().equals(actualPortalAPIResponse.getStatus()));
}
+
+ @Test
+ public void storeAnalyticsScriptIfAnalyticsTest() throws Exception
+ {
+ PortalAPIResponse expectedPortalAPIResponse = new PortalAPIResponse(true, "ok");
+ expectedPortalAPIResponse.setMessage("success");
+ EPApp appRecord =new EPApp();
+ appRecord.setName("test");
+ Mockito.when(mockedRequest.getHeader("uebkey")).thenReturn("test");
+ Mockito.when(analytics.getUserid()).thenReturn("test");
+ Mockito.when(analytics.getFunction()).thenReturn("test");
+ PortalAPIResponse actualPortalAPIResponse = webAnalyticsExtAppController.storeAnalyticsScript(mockedRequest, analytics);
+ assertTrue(expectedPortalAPIResponse.getMessage().equals(actualPortalAPIResponse.getMessage()));
+ assertTrue(expectedPortalAPIResponse.getStatus().equals(actualPortalAPIResponse.getStatus()));
+ }
+
+
+ @Test
+ public void testGetAnalyticsScript()throws Exception {
+ PowerMockito.mockStatic(SystemProperties.class);
+ Mockito.when(SystemProperties.getProperty("frontend_url")).thenReturn("http://www.ecomp.com/test");
+ webAnalyticsExtAppController.getAnalyticsScript(mockedRequest);
+
+ }
}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/BEPropertyTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/BEPropertyTest.java
new file mode 100644
index 00000000..102e6aeb
--- /dev/null
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/BEPropertyTest.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalapp.portal.domain;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class BEPropertyTest {
+
+
+ private static final String TEST="test";
+
+ @Test
+ public void test() {
+ BEProperty property=new BEProperty(TEST, TEST);
+ BEProperty beProperty=new BEProperty(TEST, TEST);
+ BEProperty be=property;
+
+ beProperty.setKey(property.getKey());
+ beProperty.setValue(property.getValue());
+
+ assertEquals(property.hashCode(), beProperty.hashCode());
+ assertTrue(beProperty.equals(property));
+ assertTrue(be.equals(property));
+ assertFalse(be.equals(null));
+ be.setValue(null);
+ assertTrue(be.equals(property));
+ be.setKey(null);
+ assertTrue(be.equals(property));
+ }
+}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/CentralRoleFunctionTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/CentralRoleFunctionTest.java
index 22777d0e..b284325f 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/CentralRoleFunctionTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/CentralRoleFunctionTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPAppTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPAppTest.java
index 7e1d7618..56f0e5ca 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPAppTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPAppTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -38,61 +38,164 @@
package org.onap.portalapp.portal.domain;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.onap.portalapp.portal.domain.EPApp;
public class EPAppTest {
+
+ private static final String TEST="test";
- public EPApp mockEPApp(){
- EPApp epApp = new EPApp();
-
- epApp.setName("test");
- epApp.setImageUrl("test");
- epApp.setDescription("test");
- epApp.setNotes("test");
- epApp.setUrl("test");
- epApp.setAlternateUrl("test");
- epApp.setAppRestEndpoint("test");
- epApp.setMlAppName("test");
- epApp.setMlAppAdminId("test");
+ public EPApp mockEPApp(EPApp epApp){
+ epApp.setId(1l);
+ epApp.setName(TEST);
+ epApp.setImageUrl(TEST);
+ epApp.setDescription(TEST);
+ epApp.setNotes(TEST);
+ epApp.setUrl(TEST);
+ epApp.setAlternateUrl(TEST);
+ epApp.setAppRestEndpoint(TEST);
+ epApp.setMlAppName(TEST);
+ epApp.setMlAppAdminId(TEST);
epApp.setMotsId((long)1);
- epApp.setUsername("test");
- epApp.setAppPassword("test");
+ epApp.setUsername(TEST);
+ epApp.setAppPassword(TEST);
epApp.setOpen(false);
epApp.setEnabled(false);
- epApp.setUebTopicName("test");
- epApp.setUebSecret("test");
+ epApp.setUebTopicName(TEST);
+ epApp.setUebSecret(TEST);
epApp.setAppType(1);
epApp.setCentralAuth(false);
- epApp.setNameSpace("test");
+ epApp.setNameSpace(TEST);
+ epApp.setRestrictedApp(true);
+ epApp.setRestrictedApp(false);
+ epApp.setAppType(null);
+ epApp.setOpen(null);
+ epApp.setThumbnail(TEST.getBytes());
+ epApp.setUebKey(TEST);
return epApp;
}
@Test
public void epAppTest(){
- EPApp epApp = mockEPApp();
+ EPApp epApp1 = new EPApp();
+ epApp1 = mockEPApp(epApp1);
+ EPApp epApp=new EPApp();
+
+ epApp.setId(epApp1.getId());
+ epApp.setName(epApp1.getName());
+ epApp.setImageUrl(epApp1.getImageUrl());
+ epApp.setDescription(epApp1.getDescription());
+ epApp.setNotes(epApp1.getNotes());
+ epApp.setUrl(epApp1.getUrl());
+ epApp.setAlternateUrl(epApp1.getAlternateUrl());
+ epApp.setAppRestEndpoint(epApp1.getAppRestEndpoint());
+ epApp.setMlAppName(epApp1.getMlAppName());
+ epApp.setMlAppAdminId(epApp1.getMlAppAdminId());
+ epApp.setMotsId(epApp1.getMotsId());
+ epApp.setUsername(epApp1.getUsername());
+ epApp.setAppPassword(epApp1.getAppPassword());
+ epApp.setOpen(epApp1.getOpen());
+ epApp.setEnabled(epApp1.getEnabled());
+ epApp.setUebTopicName(epApp1.getUebTopicName());
+ epApp.setUebSecret(epApp1.getUebSecret());
+ epApp.setAppType(epApp1.getAppType());
+ epApp.setCentralAuth(epApp1.getCentralAuth());
+ epApp.setNameSpace(epApp1.getNameSpace());
+ epApp.setRestrictedApp(epApp1.isRestrictedApp());
+
+ epApp.setAppType(epApp1.getAppType());
+
+ epApp.setThumbnail(epApp1.getThumbnail());
+ epApp.setUebKey(epApp1.getUebKey());
+ epApp.compareTo(epApp1);
+ assertEquals(epApp.hashCode(), epApp1.hashCode());
+ assertTrue(epApp.equals(epApp1));
+ assertFalse(epApp.equals(null));
+
- assertEquals(epApp.getName(), "test");
- assertEquals(epApp.getImageUrl(), "test");
- assertEquals(epApp.getDescription(), "test");
- assertEquals(epApp.getNotes(), "test");
- assertEquals(epApp.getUrl(), "test");
- assertEquals(epApp.getAlternateUrl(), "test");
- assertEquals(epApp.getAppRestEndpoint(), "test");
- assertEquals(epApp.getMlAppName(), "test");
- assertEquals(epApp.getMlAppAdminId(), "test");
+ assertEquals(epApp.getName(), TEST);
+ assertEquals(epApp.getId(), Long.valueOf(1l));
+ assertEquals(epApp.getImageUrl(), TEST);
+ assertEquals(epApp.getDescription(), TEST);
+ assertEquals(epApp.getNotes(), TEST);
+ assertEquals(epApp.getUrl(), TEST);
+ assertEquals(epApp.getAlternateUrl(), TEST);
+ assertEquals(epApp.getAppRestEndpoint(), TEST);
+ assertEquals(epApp.getMlAppName(), TEST);
+ assertEquals(epApp.getMlAppAdminId(), TEST);
assertEquals(epApp.getMotsId(), new Long(1));
- assertEquals(epApp.getUsername(), "test");
- assertEquals(epApp.getAppPassword(), "test");
+ assertEquals(epApp.getUsername(), TEST);
+ assertEquals(epApp.getAppPassword(), TEST);
assertEquals(epApp.getOpen(), false);
assertEquals(epApp.getEnabled(), false);
- assertEquals(epApp.getUebTopicName(), "test");
- assertEquals(epApp.getUebSecret(), "test");
+ assertEquals(epApp.getUebTopicName(), TEST);
+ assertEquals(epApp.getUebSecret(), TEST);
assertEquals(epApp.getAppType(), Integer.valueOf(1));
assertEquals(epApp.getCentralAuth(), false);
- assertEquals(epApp.getNameSpace(), "test");
-
- }
+ assertEquals(epApp.getNameSpace(), TEST);
+ assertEquals(epApp.getUebKey(), TEST);
+
+ assertEquals(epApp.getOpen(), false);
+ assertEquals(epApp.isRestrictedApp(), false);
+ assertEquals(epApp.hashCode(), epApp1.hashCode());
+ assertTrue(epApp.equals(epApp1));
+ //epApp.compareTo(epApp1);
+ assertNotNull(epApp.toString());
+ epApp.setContactUs(new AppContactUs());
+ assertNotNull(epApp.getContactUs());
+
+
+ epApp.setUsername(null);
+ assertFalse(epApp.equals(epApp1));
+ epApp.setUrl(null);
+ assertFalse(epApp.equals(epApp1));
+ epApp.setUebTopicName(null);
+ assertFalse(epApp.equals(epApp1));
+
+ epApp.setUebSecret(null);
+ assertFalse(epApp.equals(epApp1));
+ epApp.setUebKey(null);
+ assertFalse(epApp.equals(epApp1));
+ epApp.setOpen(null);
+ assertFalse(epApp.equals(epApp1));
+ epApp.setNotes(null);
+ assertFalse(epApp.equals(epApp1));
+ epApp.setNameSpace(null);
+ assertFalse(epApp.equals(epApp1));
+
+ epApp.setName(null);
+ assertFalse(epApp.equals(epApp1));
+ epApp.setMotsId(null);
+ assertFalse(epApp.equals(epApp1));
+ epApp.setMlAppName(null);
+ assertFalse(epApp.equals(epApp1));
+ epApp.setMlAppAdminId(null);
+ assertFalse(epApp.equals(epApp1));
+ epApp.setImageUrl(null);
+ assertFalse(epApp.equals(epApp1));
+ epApp.setEnabled(null);
+ assertFalse(epApp.equals(epApp1));
+ epApp.setDescription(null);
+ assertFalse(epApp.equals(epApp1));
+ epApp.setContactUs(null);
+ assertFalse(epApp.equals(epApp1));
+
+ epApp.setCentralAuth(null);
+ assertFalse(epApp.equals(epApp1));
+
+ epApp.setAppType(null);
+ assertFalse(epApp.equals(epApp1));
+ epApp.setAppRestEndpoint(null);
+ assertFalse(epApp.equals(epApp1));
+ epApp.setAppPassword(null);
+ assertFalse(epApp.equals(epApp1));
+
+ epApp.setAlternateUrl(null);
+ assertFalse(epApp.equals(epApp1));
+ }
}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPUserAppRolesRequestTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPUserAppRolesRequestTest.java
new file mode 100644
index 00000000..96089cd7
--- /dev/null
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/EPUserAppRolesRequestTest.java
@@ -0,0 +1,94 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalapp.portal.domain;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.junit.Test;
+
+public class EPUserAppRolesRequestTest {
+
+ private static final String TEST="test";
+ Date date=new Date();
+
+
+ @Test
+ public void testEpUserAppRoles() {
+ EPUserAppRolesRequest request=new EPUserAppRolesRequest();
+ request=buildEPUserAppRolesRequest(request);
+ EPUserAppRolesRequest request1=new EPUserAppRolesRequest();
+ request1=buildEPUserAppRolesRequest(request1);
+
+ assertEquals(request.getRequestStatus(), "test");
+ request.getAppId();
+ request.getUserId();
+ assertEquals(request.getCreated(),date);
+ assertEquals(request.getCreatedDate(),date);
+ assertEquals(request.getUpdatedDate(),date);
+ assertNotNull(request.getEpRequestIdDetail());
+ assertEquals(request.hashCode(), request1.hashCode());
+ assertTrue(request.equals(request1));
+ assertNotNull(request.toString());
+
+
+ }
+ private EPUserAppRolesRequest buildEPUserAppRolesRequest(EPUserAppRolesRequest request) {
+ request.setUserId(1l);
+ request.setAppId(1l);
+ request.setCreated(date);
+ request.setCreatedDate(date);
+ request.setUpdatedDate(date);
+ request.setRequestStatus(TEST);
+ Set<EPUserAppRolesRequestDetail> epRequestIdDetail=new HashSet<>();
+ EPUserAppRolesRequestDetail detail=new EPUserAppRolesRequestDetail();
+ detail.setId(1l);
+ epRequestIdDetail.add(detail);
+ request.setEpRequestIdDetail(epRequestIdDetail);
+
+ return request;
+ }
+
+}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/ExternalSystemAccessTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/ExternalSystemAccessTest.java
index d51d5e5c..f99149da 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/ExternalSystemAccessTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/domain/ExternalSystemAccessTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -38,9 +38,10 @@
package org.onap.portalapp.portal.domain;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import org.junit.Test;
-import org.onap.portalapp.portal.domain.ExternalSystemAccess;
public class ExternalSystemAccessTest {
@@ -52,13 +53,23 @@ public class ExternalSystemAccessTest {
return externalSystemAccess;
}
+
+
@Test
public void externalSystemAccessTest(){
- ExternalSystemAccess externalSystemAccess = mockExternalSystemAccess();
+ ExternalSystemAccess externalSystem=mockExternalSystemAccess();
+ ExternalSystemAccess externalSystemAccess = new ExternalSystemAccess("test", false);
+ externalSystemAccess.setKey(externalSystem.getKey());
+ externalSystemAccess.setAccessValue(externalSystem.getAccessValue());
+ assertEquals(externalSystemAccess.hashCode(), externalSystem.hashCode());
+ assertTrue(externalSystemAccess.equals(externalSystem));
+ assertFalse(externalSystemAccess.equals(null));
- assertEquals(externalSystemAccess.getKey(), "test");
- assertEquals(externalSystemAccess.getAccessValue(), false);
+ externalSystemAccess.setKey(null);
+ assertFalse(externalSystemAccess.equals(externalSystem));
+ externalSystemAccess.setAccessValue(null);
+ assertFalse(externalSystemAccess.equals(externalSystem));
}
}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/listener/UserSessionListenerTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/listener/UserSessionListenerTest.java
new file mode 100644
index 00000000..56668386
--- /dev/null
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/listener/UserSessionListenerTest.java
@@ -0,0 +1,99 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalapp.portal.listener;
+
+import static org.mockito.Mockito.*;
+import java.util.HashMap;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpSessionEvent;
+
+import org.apache.commons.collections4.map.HashedMap;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.portalapp.portal.service.SharedContextService;
+
+public class UserSessionListenerTest {
+
+ @InjectMocks
+ UserSessionListener userSessionListener;
+
+ @Mock
+ SharedContextService sharedContextService;
+ @Mock
+ HttpSessionEvent event;
+ @Mock
+ HttpSession session;
+ @Mock
+ ServletContext context;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testSessionCreate() {
+
+ Mockito.when(event.getSession()).thenReturn(session);
+ Mockito.when(session.getServletContext()).thenReturn(context);
+ when(context.getAttribute("activeUsers")).thenReturn(new HashMap());
+ userSessionListener.sessionCreated(event);
+
+
+ }
+
+ @Test
+ public void testSessionDestroyed() {
+
+ HashMap activeUsers=new HashMap<>();
+
+ when(session.getId()).thenReturn("TestSession");
+ activeUsers.put("TestSession", session);
+ Mockito.when(event.getSession()).thenReturn(session);
+ Mockito.when(session.getServletContext()).thenReturn(context);
+ when(context.getAttribute("activeUsers")).thenReturn(activeUsers);
+ userSessionListener.sessionDestroyed(event);
+ }
+
+}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/logging/logic/AuxDiscriminatorTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/logging/logic/AuxDiscriminatorTest.java
new file mode 100644
index 00000000..d649c34b
--- /dev/null
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/logging/logic/AuxDiscriminatorTest.java
@@ -0,0 +1,98 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalapp.portal.logging.logic;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import ch.qos.logback.classic.spi.ILoggingEvent;
+
+public class AuxDiscriminatorTest {
+
+ @InjectMocks
+ AuxDiscriminator auxDiscriminator;
+ @Mock
+ ILoggingEvent event;
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+
+ @Test
+ public void getDiscriminatingValue() {
+ when(event.getMessage()).thenReturn("org.onap.music.Test");
+ Map<String, String> mdcMap =new HashMap<>();
+ when( event.getMDCPropertyMap()).thenReturn(mdcMap) ;
+
+ String data= auxDiscriminator.getDiscriminatingValue(event);
+ assertNotNull(data);
+
+
+ }
+
+ @Test
+ public void getDiscriminatingValueTest() {
+ when(event.getMessage()).thenReturn("org.onap.portalapp.portal.transport.RemoteRoleV1.java");
+ Map<String, String> mdcMap =new HashMap<>();
+ when( event.getMDCPropertyMap()).thenReturn(mdcMap) ;
+
+ auxDiscriminator.getDiscriminatingValue(event);
+
+ }
+
+ @Test
+ public void getDiscriminatingValueTestEmptyMap() {
+ when(event.getMessage()).thenReturn("org.onap.portalapp.portal.transport.RemoteRoleV1.java");
+ when( event.getMDCPropertyMap()).thenReturn(null) ;
+
+ auxDiscriminator.getDiscriminatingValue(event);
+
+ }
+
+
+}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/model/AppCategoryFunctionsItemTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/model/AppCategoryFunctionsItemTest.java
index 9c9c105e..72d76d49 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/model/AppCategoryFunctionsItemTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/model/AppCategoryFunctionsItemTest.java
@@ -38,20 +38,25 @@
package org.onap.portalapp.portal.model;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.onap.portalapp.portal.ecomp.model.AppCategoryFunctionsItem;
public class AppCategoryFunctionsItemTest {
+
+ private static final String TEST="test";
- public AppCategoryFunctionsItem mockAppCategoryFunctionsItem(){
+ private AppCategoryFunctionsItem mockAppCategoryFunctionsItem(){
AppCategoryFunctionsItem appCategoryFunctionsItem = new AppCategoryFunctionsItem();
- appCategoryFunctionsItem.setRowId("test");
- appCategoryFunctionsItem.setAppId("test");
- appCategoryFunctionsItem.setApplication("test");
- appCategoryFunctionsItem.setFunctions("test");
+ appCategoryFunctionsItem.setRowId(TEST);
+ appCategoryFunctionsItem.setAppId(TEST);
+ appCategoryFunctionsItem.setApplication(TEST);
+ appCategoryFunctionsItem.setFunctions(TEST);
+ appCategoryFunctionsItem.setCategory(TEST);
return appCategoryFunctionsItem;
}
@@ -62,18 +67,28 @@ public class AppCategoryFunctionsItemTest {
AppCategoryFunctionsItem appCategoryFunctionsItem1 = new AppCategoryFunctionsItem();
- appCategoryFunctionsItem1.setRowId("test");
- appCategoryFunctionsItem1.setAppId("test");
- appCategoryFunctionsItem1.setApplication("test");
- appCategoryFunctionsItem1.setFunctions("test");
-
- assertEquals(appCategoryFunctionsItem.getRowId(), appCategoryFunctionsItem1.getRowId());
- assertEquals(appCategoryFunctionsItem.getAppId(), appCategoryFunctionsItem1.getAppId());
- assertEquals(appCategoryFunctionsItem.getApplication(), appCategoryFunctionsItem1.getApplication());
- assertEquals(appCategoryFunctionsItem.getFunctions(), appCategoryFunctionsItem1.getFunctions());
- assertEquals(appCategoryFunctionsItem.toString(), "AppCategoryFunctionsItem [rowId=test, appId=test, application=test, category=null, functions=test]");
+ appCategoryFunctionsItem1.setRowId(appCategoryFunctionsItem.getRowId());
+ appCategoryFunctionsItem1.setAppId(appCategoryFunctionsItem.getAppId());
+ appCategoryFunctionsItem1.setApplication(appCategoryFunctionsItem.getApplication());
+ appCategoryFunctionsItem1.setFunctions(appCategoryFunctionsItem.getFunctions());
+ appCategoryFunctionsItem1.setCategory(appCategoryFunctionsItem.getCategory());
+ assertNotNull(appCategoryFunctionsItem.toString());
assertEquals(appCategoryFunctionsItem.hashCode(), appCategoryFunctionsItem1.hashCode());
- assertTrue(appCategoryFunctionsItem.equals(appCategoryFunctionsItem1));
+ assertTrue(appCategoryFunctionsItem1.equals(appCategoryFunctionsItem));
+
+ assertFalse(appCategoryFunctionsItem1.equals(null));
+ appCategoryFunctionsItem1.setRowId(null);
+ assertFalse(appCategoryFunctionsItem1.equals(appCategoryFunctionsItem));
+ appCategoryFunctionsItem1.setFunctions(null);
+ assertFalse(appCategoryFunctionsItem1.equals(appCategoryFunctionsItem));
+ appCategoryFunctionsItem1.setCategory(null);
+ assertFalse(appCategoryFunctionsItem1.equals(appCategoryFunctionsItem));
+ appCategoryFunctionsItem1.setApplication(null);
+
+ assertFalse(appCategoryFunctionsItem1.equals(appCategoryFunctionsItem));
+appCategoryFunctionsItem1.setAppId(null);
+
+ assertFalse(appCategoryFunctionsItem1.equals(appCategoryFunctionsItem));
}
}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/model/AppContactUsItemTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/model/AppContactUsItemTest.java
index 528f0fed..bc1be847 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/model/AppContactUsItemTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/model/AppContactUsItemTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -38,6 +38,8 @@
package org.onap.portalapp.portal.model;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
@@ -45,42 +47,53 @@ import org.onap.portalapp.portal.ecomp.model.AppContactUsItem;
public class AppContactUsItemTest {
+ private static final String TEST="test";
+
public AppContactUsItem mockAppContactUsItem(){
AppContactUsItem appContactUsItem = new AppContactUsItem();
appContactUsItem.setAppId((long)1);
- appContactUsItem.setAppName("test");
- appContactUsItem.setDescription("test");
- appContactUsItem.setContactName("test");
- appContactUsItem.setContactEmail("test");
- appContactUsItem.setUrl("test");
- appContactUsItem.setActiveYN("test");
+ appContactUsItem.setAppName(TEST);
+ appContactUsItem.setDescription(TEST);
+ appContactUsItem.setContactName(TEST);
+ appContactUsItem.setContactEmail(TEST);
+ appContactUsItem.setUrl(TEST);
+ appContactUsItem.setActiveYN(TEST);
return appContactUsItem;
}
+
@Test
public void appContactUsItemTest(){
- AppContactUsItem appContactUsItem = mockAppContactUsItem();
+ AppContactUsItem appContactUsItem1 = mockAppContactUsItem();
- AppContactUsItem appContactUsItem1 = new AppContactUsItem();
- appContactUsItem1.setAppId((long)1);
- appContactUsItem1.setAppName("test");
- appContactUsItem1.setDescription("test");
- appContactUsItem1.setContactName("test");
- appContactUsItem1.setContactEmail("test");
- appContactUsItem1.setUrl("test");
- appContactUsItem1.setActiveYN("test");
+ AppContactUsItem appContactUsItem = new AppContactUsItem();
+ appContactUsItem.setAppId(appContactUsItem1.getAppId());
+ appContactUsItem.setAppName(appContactUsItem1.getAppName());
+ appContactUsItem.setDescription(appContactUsItem1.getDescription());
+ appContactUsItem.setContactName(appContactUsItem1.getContactName());
+ appContactUsItem.setContactEmail(appContactUsItem1.getContactEmail());
+ appContactUsItem.setUrl(appContactUsItem1.getUrl());
+ appContactUsItem.setActiveYN(appContactUsItem1.getActiveYN());
+ assertNotNull(appContactUsItem.toString());
- assertEquals(appContactUsItem.getAppId(), appContactUsItem1.getAppId());
- assertEquals(appContactUsItem.getAppName(), appContactUsItem1.getAppName());
- assertEquals(appContactUsItem.getDescription(), appContactUsItem1.getDescription());
- assertEquals(appContactUsItem.getContactName(), appContactUsItem1.getContactName());
- assertEquals(appContactUsItem.getContactEmail(), appContactUsItem1.getContactEmail());
- assertEquals(appContactUsItem.getUrl(), appContactUsItem1.getUrl());
- assertEquals(appContactUsItem.getActiveYN(), appContactUsItem1.getActiveYN());
- assertEquals(appContactUsItem.toString(), "AppContactUsItem [appId=1, appName=test, description=test, contactName=test, contactEmail=test, url=test, activeYN=test]");
assertEquals(appContactUsItem.hashCode(), appContactUsItem1.hashCode());
assertTrue(appContactUsItem.equals(appContactUsItem1));
+ assertFalse(appContactUsItem.equals(null));
+ appContactUsItem.setUrl(null);
+ assertFalse(appContactUsItem.equals(appContactUsItem1));
+ appContactUsItem.setDescription(null);
+ assertFalse(appContactUsItem.equals(appContactUsItem1));
+ appContactUsItem.setContactName(null);
+ assertFalse(appContactUsItem.equals(appContactUsItem1));
+ appContactUsItem.setContactEmail(null);
+ assertFalse(appContactUsItem.equals(appContactUsItem1));
+ appContactUsItem.setAppName(null);
+ assertFalse(appContactUsItem.equals(appContactUsItem1));
+ appContactUsItem.setAppId(null);
+ assertFalse(appContactUsItem.equals(appContactUsItem1));
+ appContactUsItem.setActiveYN(null);
+ assertFalse(appContactUsItem.equals(appContactUsItem1));
}
}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/scheduler/SchedulerResponseWrapperTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/scheduler/SchedulerResponseWrapperTest.java
new file mode 100644
index 00000000..f9a2ead6
--- /dev/null
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/scheduler/SchedulerResponseWrapperTest.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalapp.portal.scheduler;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+
+public class SchedulerResponseWrapperTest {
+ private static final String TEST="test";
+@Test
+public void getResponse()throws Exception {
+
+ SchedulerResponseWrapper wrapper=new SchedulerResponseWrapper();
+ wrapper.setEntity(TEST);
+ wrapper.setStatus(200);
+wrapper.setUuid(TEST);
+
+assertNotNull(wrapper.toString());
+assertNotNull(wrapper.getResponse());
+}
+
+}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/scheduler/util/CustomJacksonJaxBJsonProviderTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/scheduler/util/CustomJacksonJaxBJsonProviderTest.java
new file mode 100644
index 00000000..dc3cad14
--- /dev/null
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/scheduler/util/CustomJacksonJaxBJsonProviderTest.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalapp.portal.scheduler.util;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+
+public class CustomJacksonJaxBJsonProviderTest {
+
+ @Test
+ public void test() {
+ CustomJacksonJaxBJsonProvider mapper=new CustomJacksonJaxBJsonProvider();
+ assertNotNull(mapper.getMapper());
+ }
+
+}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxRestIntTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxRestIntTest.java
new file mode 100644
index 00000000..48471f85
--- /dev/null
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxRestIntTest.java
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalapp.portal.scheduleraux;
+
+import org.junit.Test;
+import org.onap.portalapp.portal.scheduler.policy.rest.RequestDetails;
+
+public class SchedulerAuxRestIntTest {
+
+ @Test
+ public void logRequest() {
+
+ RequestDetails requestDetails=new RequestDetails();
+ requestDetails.setPolicyName("test");
+
+ SchedulerAuxRestInt schedulerAuxRestInt=new SchedulerAuxRestInt();
+ schedulerAuxRestInt.logRequest(requestDetails);
+
+ }
+
+
+
+
+
+}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxUtilTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxUtilTest.java
new file mode 100644
index 00000000..b8fb3fc4
--- /dev/null
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxUtilTest.java
@@ -0,0 +1,82 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalapp.portal.scheduleraux;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+
+import org.glassfish.jersey.client.ClientResponse;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+public class SchedulerAuxUtilTest {
+
+ private static final String TEST="test";
+
+ @InjectMocks
+ SchedulerAuxUtil schedulerAuxUtil;
+ @Mock
+ RestObject<String> rs;
+ @Mock
+ ClientResponse cres;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testWrapResponse() {
+
+ // schedulerAuxUtil.wrapResponse(TEST, 200);
+
+ when(rs.get()).thenReturn(TEST);
+ when(rs.getStatusCode()).thenReturn(200);
+ SchedulerAuxResponseWrapper response= schedulerAuxUtil.wrapResponse(rs);
+ assertEquals(TEST, response.getEntity());
+ assertEquals(200, response.getStatus());
+ when(cres.readEntity(String.class)).thenReturn(TEST);
+ when(cres.getStatus()).thenReturn(200);
+ schedulerAuxUtil.wrapResponse(cres);
+
+
+ }
+}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/AppContactUsServiceImplTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/AppContactUsServiceImplTest.java
index 3777f8aa..acc25ac8 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/AppContactUsServiceImplTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/AppContactUsServiceImplTest.java
@@ -49,6 +49,7 @@ import javax.servlet.http.HttpServletResponse;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
+import org.mockito.Matchers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
@@ -66,16 +67,10 @@ public class AppContactUsServiceImplTest {
@Mock
- DataAccessService dataAccessService = new DataAccessServiceImpl();
+ DataAccessService dataAccessService ;
@Mock
- AppContactUsService AppContactUsService = new AppContactUsServiceImpl();
-
- @Before
- public void setup() {
- MockitoAnnotations.initMocks(this);
- }
-
+ AppContactUsService AppContactUsService ;
@InjectMocks
AppContactUsServiceImpl appContactUsServiceImpl = new AppContactUsServiceImpl();
@@ -83,6 +78,13 @@ public class AppContactUsServiceImplTest {
HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+
NullPointerException nullPointerException = new NullPointerException();
@@ -140,6 +142,7 @@ public class AppContactUsServiceImplTest {
assertEquals(expectedcontactUsItemList, contactUsItemList);
}
+
@Test
public void getAppCategoryFunctionsTest() throws Exception
{
@@ -172,13 +175,39 @@ public class AppContactUsServiceImplTest {
appContactUsServiceImpl.saveAppContactUs(contactUsModelList);
}
+ @Test
+ public void saveAppContacts()throws Exception {
+
+ List<AppContactUsItem> contactUsModelList = new ArrayList<>();
+ AppContactUsItem appContactUsItem= new AppContactUsItem();
+ appContactUsItem.setAppId((long) 1);
+ contactUsModelList.add(appContactUsItem);
+ HashMap<String, Object> map = new HashMap<String, Object>();
+
+ Mockito.when(dataAccessService.getDomainObject(AppContactUs.class,
+ appContactUsItem.getAppId(), map)).thenReturn(appContactUsItem);
+
+ Mockito.when(dataAccessService.getDomainObject(EPApp.class, appContactUsItem.getAppId(), map)).thenReturn(getApp());
+ appContactUsServiceImpl.saveAppContactUs(contactUsModelList);
+ }
+
@Test(expected = java.lang.NullPointerException.class)
- public void deleteContactUsTest() throws Exception
+ public void deleteContactUs_error_Test() throws Exception
{
HashMap<String, Object> map = new HashMap<String, Object>();
AppContactUs contactUs = new AppContactUs();
Mockito.when((AppContactUs) dataAccessService.getDomainObject(AppContactUs.class, 1, map)).thenReturn(contactUs);
appContactUsServiceImpl.deleteContactUs((long) 1);
}
+ @Test(expected=Exception.class)
+ public void deleteContactUsTest()throws Exception {
+ HashMap<String, Object> map = new HashMap<String, Object>();
+
+ AppContactUs contactUs = new AppContactUs();
+ contactUs.setId(1l);
+ Mockito.when(dataAccessService.getDomainObject(AppContactUs.class,
+ contactUs.getId(), map)).thenReturn(contactUs);
+ appContactUsServiceImpl.deleteContactUs( contactUs.getId());
+ }
}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/BasicAuthAccountServiceImplTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/BasicAuthAccountServiceImplTest.java
index 54347495..4409a4fc 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/BasicAuthAccountServiceImplTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/BasicAuthAccountServiceImplTest.java
@@ -175,4 +175,17 @@ public class BasicAuthAccountServiceImplTest {
basicAuthAccountServiceImpl.deleteEndpointAccout(1l);
}
+
+ @Test
+ public void getBasicAuthCredentialsById() throws Exception{
+ List<BasicAuthCredentials> list = new ArrayList<>();
+ BasicAuthCredentials basicAuthCredentials = new BasicAuthCredentials();
+ basicAuthCredentials.setPassword("password");
+ basicAuthCredentials.setId(1l);
+ list.add(basicAuthCredentials);
+ Mockito.when((List<BasicAuthCredentials>) dataAccessService.getList(BasicAuthCredentials.class, null))
+ .thenReturn(list);
+ basicAuthAccountServiceImpl.getBasicAuthCredentialsById(1l);
+
+ }
}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/ConsulHealthServiceImplTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/ConsulHealthServiceImplTest.java
new file mode 100644
index 00000000..71bdb7c0
--- /dev/null
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/ConsulHealthServiceImplTest.java
@@ -0,0 +1,184 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalapp.portal.service;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.*;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.onap.portalapp.portal.utils.EcompPortalUtils;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import com.orbitz.consul.Consul;
+import com.orbitz.consul.HealthClient;
+import com.orbitz.consul.model.ConsulResponse;
+import com.orbitz.consul.model.health.ServiceHealth;
+import com.orbitz.consul.Consul.Builder;
+import com.orbitz.consul.model.health.Node;
+import com.orbitz.consul.model.health.Service;
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ Consul.class ,EcompPortalUtils.class})
+public class ConsulHealthServiceImplTest {
+
+ private static final String TEST="test";
+ @InjectMocks
+ ConsulHealthServiceImpl consulHealthServiceImpl;
+
+ @Mock
+ Builder builder;
+ @Mock
+ Consul consul ;
+ @Mock
+ HealthClient healthClient;
+ @Mock
+ ServiceHealth serviceHealth;
+ @Mock
+ ConsulResponse<List<ServiceHealth>> response;
+ @Mock
+ Node node;
+ @Mock
+ Service service;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void getServiceLocation_Error() {
+
+ PowerMockito.mockStatic(Consul.class);
+ PowerMockito.mockStatic(EcompPortalUtils.class);
+ PowerMockito.when(Consul.builder()).thenReturn(builder);
+ PowerMockito.when(EcompPortalUtils.localOrDockerHost()).thenReturn(TEST);
+ when(builder.build()).thenReturn(consul);
+ when(consul.healthClient()).thenReturn(healthClient);
+ String location= consulHealthServiceImpl.getServiceLocation(TEST, TEST);
+ assertNotNull(location);
+
+ }
+
+ @Test
+ public void getServiceLocation_Empty() {
+
+ List<ServiceHealth> nodes=new ArrayList<>();
+ nodes.add(serviceHealth);
+
+ PowerMockito.mockStatic(Consul.class);
+ PowerMockito.mockStatic(EcompPortalUtils.class);
+ PowerMockito.when(Consul.builder()).thenReturn(builder);
+ PowerMockito.when(EcompPortalUtils.localOrDockerHost()).thenReturn(TEST);
+ when(builder.build()).thenReturn(consul);
+ when(consul.healthClient()).thenReturn(healthClient);
+ when( healthClient.getHealthyServiceInstances(TEST)).thenReturn(null);
+
+
+ String location= consulHealthServiceImpl.getServiceLocation(TEST, TEST);
+ assertNotNull(location);
+
+ }
+
+
+ @Test
+ public void getServiceLocation() {
+
+ List<ServiceHealth> nodes=new ArrayList<>();
+ nodes.add(serviceHealth);
+
+ PowerMockito.mockStatic(Consul.class);
+ PowerMockito.mockStatic(EcompPortalUtils.class);
+ PowerMockito.when(Consul.builder()).thenReturn(builder);
+ PowerMockito.when(EcompPortalUtils.localOrDockerHost()).thenReturn(TEST);
+ when(builder.build()).thenReturn(consul);
+ when(consul.healthClient()).thenReturn(healthClient);
+ when( healthClient.getHealthyServiceInstances(TEST)).thenReturn(response);
+ when(response.getResponse()).thenReturn(nodes);
+ when(serviceHealth.getNode()).thenReturn(node);
+ when(serviceHealth.getService()).thenReturn(service);
+
+ String location= consulHealthServiceImpl.getServiceLocation(TEST, TEST);
+ assertNotNull(location);
+
+ }
+
+ @Test
+ public void getAllHealthyNodes() {
+ List<ServiceHealth> nodes=new ArrayList<>();
+ nodes.add(serviceHealth);
+
+ PowerMockito.mockStatic(Consul.class);
+ PowerMockito.when(Consul.builder()).thenReturn(builder);
+
+ when(builder.build()).thenReturn(consul);
+ when(consul.healthClient()).thenReturn(healthClient);
+ when( healthClient.getHealthyServiceInstances(TEST)).thenReturn(response);
+ when(response.getResponse()).thenReturn(nodes);
+ List<ServiceHealth> list= consulHealthServiceImpl.getAllHealthyNodes(TEST);
+ assertEquals(1, list.size());
+
+ }
+
+ @Test
+ public void getAllNodes() {
+ List<ServiceHealth> nodes=new ArrayList<>();
+ nodes.add(serviceHealth);
+
+ PowerMockito.mockStatic(Consul.class);
+ PowerMockito.when(Consul.builder()).thenReturn(builder);
+
+ when(builder.build()).thenReturn(consul);
+ when(consul.healthClient()).thenReturn(healthClient);
+ when( healthClient.getAllServiceInstances(TEST)).thenReturn(response);
+ when(response.getResponse()).thenReturn(nodes);
+ List<ServiceHealth> list= consulHealthServiceImpl.getAllNodes(TEST);
+ assertEquals(1, list.size());
+ }
+
+}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/MicroserviceServiceImplTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/MicroserviceServiceImplTest.java
index 1c8503d6..ae813152 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/MicroserviceServiceImplTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/MicroserviceServiceImplTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -51,7 +51,6 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
-import org.mockito.Matchers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
@@ -70,6 +69,7 @@ import org.powermock.modules.junit4.PowerMockRunner;
@PrepareForTest({Criterion.class, Restrictions.class, CipherUtil.class, EPCommonSystemProperties.class, SystemProperties.class, Restrictions.class})
public class MicroserviceServiceImplTest {
+ private static final String TEST="test";
@Mock
DataAccessService dataAccessService = new DataAccessServiceImpl();
@@ -204,4 +204,72 @@ public class MicroserviceServiceImplTest {
List<MicroserviceData> actual = microserviceServiceImpl.getMicroserviceData();
assertNotNull(actual);
}
+
+ @Test
+ public void updateMicroservice()throws Exception {
+
+ List<MicroserviceParameter> microserviceParameters = new ArrayList<>();
+ MicroserviceParameter microserviceParameter = new MicroserviceParameter();
+ microserviceParameter.setId(1l);
+ microserviceParameter.setPara_key(TEST);
+ microserviceParameter.setPara_value(TEST);
+ microserviceParameters.add(microserviceParameter);
+ List<Criterion> restrictionsList = new ArrayList<Criterion>();
+
+ PowerMockito.mockStatic(Restrictions.class);
+ PowerMockito.mockStatic(CipherUtil.class);
+ Criterion serviceIdCriterion = Restrictions.eq("serviceId", 1l);
+ restrictionsList.add(serviceIdCriterion);
+ PowerMockito.mockStatic(SystemProperties.class);
+ Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(TEST);
+ Mockito.when(CipherUtil.encryptPKC(TEST, TEST)).thenReturn(TEST);
+
+ Mockito.when((List<MicroserviceParameter>) dataAccessService.getList(MicroserviceParameter.class, null, restrictionsList, null)).thenReturn(microserviceParameters);
+ microserviceServiceImpl.updateMicroservice(1l, buildData());
+
+ }
+
+ @Test
+ public void getParametersById() {
+ List<Criterion> restrictionsList = new ArrayList<Criterion>();
+ PowerMockito.mockStatic(Restrictions.class);
+ PowerMockito.mockStatic(CipherUtil.class);
+ Criterion serviceIdCriterion = Restrictions.eq("serviceId", 1l);
+ restrictionsList.add(serviceIdCriterion);
+ Mockito.when((List<MicroserviceParameter>) dataAccessService.getList(MicroserviceParameter.class, null, restrictionsList, null)).thenReturn(buildData().getParameterList());
+
+ List<MicroserviceParameter> parameters= microserviceServiceImpl.getParametersById(1l);
+ assertEquals(TEST, parameters.get(0).getPara_key());
+ }
+
+ @Test
+ public void deleteMicroservice()throws Exception {
+ microserviceServiceImpl.deleteMicroservice(1l);
+
+ }
+
+
+ public MicroserviceData buildData() {
+ MicroserviceData microserviceData=new MicroserviceData();
+ microserviceData.setId((long)1);
+ microserviceData.setName(TEST);
+ microserviceData.setActive(TEST);
+ microserviceData.setDesc(TEST);
+ microserviceData.setAppId((long)1);
+ microserviceData.setUrl(TEST);
+ microserviceData.setSecurityType(TEST);
+ microserviceData.setUsername(TEST);
+ microserviceData.setPassword(TEST);
+
+ List<MicroserviceParameter> microserviceParameters = new ArrayList<>();
+ MicroserviceParameter microserviceParameter = new MicroserviceParameter();
+ microserviceParameter.setId(1l);
+ microserviceParameter.setPara_key(TEST);
+ microserviceParameter.setPara_value(TEST);
+ microserviceParameters.add(microserviceParameter);
+ microserviceData.setParameterList(microserviceParameters);
+
+ return microserviceData;
+ }
+
}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/UserServiceImplTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/UserServiceImplTest.java
index e2cc3225..20bc8b4d 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/UserServiceImplTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/UserServiceImplTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -38,143 +38,215 @@
package org.onap.portalapp.portal.service;
import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.*;
import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;
import org.json.simple.JSONObject;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
-import org.onap.portalapp.portal.core.MockEPUser;
-import org.onap.portalapp.portal.domain.EPApp;
import org.onap.portalapp.portal.domain.EPUser;
import org.onap.portalapp.portal.utils.EPCommonSystemProperties;
-import org.onap.portalapp.portal.utils.EcompPortalUtils;
-import org.onap.portalapp.portal.utils.PortalConstants;
import org.onap.portalsdk.core.onboarding.util.CipherUtil;
import org.onap.portalsdk.core.service.DataAccessService;
-import org.onap.portalsdk.core.service.DataAccessServiceImpl;
import org.onap.portalsdk.core.util.SystemProperties;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
-@PrepareForTest({ EcompPortalUtils.class, SystemProperties.class, PortalConstants.class,
- EPCommonSystemProperties.class, Criterion.class, CipherUtil.class, Restrictions.class })
-@Ignore
+@PrepareForTest({ SystemProperties.class, EPCommonSystemProperties.class, CipherUtil.class })
public class UserServiceImplTest {
- @Mock
- DataAccessService dataAccessService = new DataAccessServiceImpl();
-
+ private static final String TEST = "test";
+
@InjectMocks
- UserServiceImpl userServiceImpl= new UserServiceImpl();
-
+ UserServiceImpl userServiceImpl = new UserServiceImpl();
+
+ @Mock
+ DataAccessService dataAccessService;
+
+ @Mock
+ HttpURLConnection con;
+
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
}
-
- public EPApp mockApp() {
- EPApp app = new EPApp();
- app.setName("Test");
- app.setImageUrl("test");
- app.setNameSpace("com.test.app");
- app.setCentralAuth(true);
- app.setDescription("test");
- app.setNotes("test");
- app.setUrl("test");
- app.setId((long) 10);
- app.setAppRestEndpoint("test");
- app.setAlternateUrl("test");
- app.setName("test");
- app.setMlAppName("test");
- app.setMlAppAdminId("test");
- app.setUsername("test");
- app.setAppPassword("test");
- app.setOpen(false);
- app.setEnabled(true);
- app.setUebKey("test");
- app.setUebSecret("test");
- app.setUebTopicName("test");
- app.setAppType(1);
- return app;
- }
-
- MockEPUser mockUser = new MockEPUser();
-
- @SuppressWarnings("unchecked")
+
@Test
- public void getUserByUserIdExceptionTest() throws Exception {
+ public void getUserByUserIdTest() throws UnsupportedEncodingException, IOException {
+
PowerMockito.mockStatic(SystemProperties.class);
- EPUser user = mockUser.mockEPUser();
+ EPUser user = buildEpUser();
Mockito.when(SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM)).thenReturn("OIDC");
- Mockito.when(EPCommonSystemProperties.getProperty(EPCommonSystemProperties.AUTH_USER_SERVER)).thenReturn("http://www.test.com");
+ Mockito.when(EPCommonSystemProperties.getProperty(EPCommonSystemProperties.AUTH_USER_SERVER))
+ .thenReturn("http://www.test.com");
HttpURLConnection connection = Mockito.mock(HttpURLConnection.class);
+
JSONObject response = new JSONObject();
JSONObject userJson = new JSONObject();
userJson.put("id", 1);
userJson.put("givenName", "Guest");
- userJson.put("familyName", "Test");
+ userJson.put("familyName", TEST);
userJson.put("email", "test@123.com");
- List<JSONObject> userListJson = new ArrayList<>();
+ List<JSONObject> userListJson = new ArrayList<>();
userListJson.add(userJson);
response.put("response", userListJson);
ByteArrayInputStream getBody = new ByteArrayInputStream(response.toString().getBytes("UTF-8"));
PowerMockito.when(connection.getInputStream()).thenReturn(getBody);
userServiceImpl.getUserByUserId(user.getOrgUserId());
}
-
- @SuppressWarnings("unchecked")
+
+ @Test
+ public void testGetUserByNameInvalidODC() throws Exception {
+
+ PowerMockito.mockStatic(SystemProperties.class);
+ Mockito.when(SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM)).thenReturn(TEST);
+ List list = new ArrayList<>();
+ StringBuffer criteria = new StringBuffer();
+ String firstName = TEST;
+ String lastName = TEST;
+ if (firstName != null)
+ criteria.append(" where first_name = '").append(firstName).append("'");
+ if (lastName != null)
+ criteria.append(" where last_name = '").append(lastName).append("'");
+ when(dataAccessService.getList(EPUser.class, criteria.toString(), null, null)).thenReturn(list);
+ userServiceImpl.getUserByFirstLastName(TEST, TEST);
+
+ }
+
+ @Test
+ public void testGetUserByName() throws Exception {
+
+ PowerMockito.mockStatic(SystemProperties.class);
+ EPUser user = buildEpUser();
+ Mockito.when(SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM)).thenReturn("OIDC");
+ Mockito.when(EPCommonSystemProperties.getProperty(EPCommonSystemProperties.AUTH_USER_SERVER))
+ .thenReturn("http://www.test.com");
+ //HttpURLConnection connection = Mockito.mock(HttpURLConnection.class);
+ JSONObject response = new JSONObject();
+ JSONObject userJson = new JSONObject();
+ userJson.put("id", 1);
+ userJson.put("givenName", "Guest");
+ userJson.put("familyName", TEST);
+ userJson.put("email", "test@123.com");
+ List<JSONObject> userListJson = new ArrayList<>();
+ userListJson.add(userJson);
+ response.put("response", userListJson);
+ //ByteArrayInputStream getBody = new ByteArrayInputStream(response.toString().getBytes("UTF-8"));
+ //PowerMockito.when(connection.getInputStream()).thenReturn(getBody);
+ userServiceImpl.getUserByFirstLastName(TEST, TEST);
+
+ }
+
@Test
public void saveNewUserTest() throws Exception {
- PowerMockito.mockStatic(Restrictions.class);
+
PowerMockito.mockStatic(Criterion.class);
PowerMockito.mockStatic(CipherUtil.class);
- EPUser user = mockUser.mockEPUser();
- List<EPUser> users = new ArrayList<>();
+ EPUser user = buildEpUser();
+ List users = new ArrayList<>();
+ users.add(user);
Mockito.when(CipherUtil.encryptPKC(user.getLoginPwd())).thenReturn("xyz");
List<Criterion> restrictionsList = new ArrayList<Criterion>();
- Criterion orgUserIdCriterion = Restrictions.eq("orgUserId",user.getLoginId());
+ Criterion orgUserIdCriterion = Restrictions.eq("orgUserId", user.getLoginId());
restrictionsList.add(orgUserIdCriterion);
- Mockito.when((List<EPUser>) dataAccessService.getList(EPUser.class, null, restrictionsList, null)).thenReturn(users);
+
+ when( dataAccessService.getList(EPUser.class, null, restrictionsList, null)).thenReturn(users);
String actual = userServiceImpl.saveNewUser(user, "No");
assertEquals("success", actual);
+
}
-
- @SuppressWarnings("unchecked")
+
@Test
- public void saveExistingUserTest() throws Exception {
+ public void saveNewUserEmptyTest() throws Exception {
PowerMockito.mockStatic(Restrictions.class);
PowerMockito.mockStatic(Criterion.class);
PowerMockito.mockStatic(CipherUtil.class);
- EPUser user = mockUser.mockEPUser();
- user.setLoginPwd("xyz");
- List<EPUser> users = new ArrayList<>();
- users.add(user);
- EPUser oldUser = mockUser.mockEPUser();
- oldUser.setLoginPwd("abc");
- List<EPUser> oldUsers = new ArrayList<>();
- oldUsers.add(oldUser);
+ EPUser user = buildEpUser();
+ List users = new ArrayList<>();
Mockito.when(CipherUtil.encryptPKC(user.getLoginPwd())).thenReturn("xyz");
List<Criterion> restrictionsList = new ArrayList<Criterion>();
- Criterion orgUserIdCriterion = Restrictions.eq("orgUserId",user.getLoginId());
+ Criterion orgUserIdCriterion = Restrictions.eq("orgUserId", user.getLoginId());
restrictionsList.add(orgUserIdCriterion);
- Mockito.when((List<EPUser>) dataAccessService.getList(EPUser.class, null, restrictionsList, null)).thenReturn(oldUsers);
+ StringBuffer criteria = new StringBuffer();
+ criteria.append(" where org_user_id = '").append(user.getLoginId()).append("'");
+ Mockito.when(dataAccessService.getList(EPUser.class, criteria.toString(), null, null)).thenReturn(users);
String actual = userServiceImpl.saveNewUser(user, "No");
assertEquals("success", actual);
- }
+ }
+ @Test
+ public void saveUser()throws Exception {
+
+ EPUser user = buildEpUser();
+ userServiceImpl.saveUser(user);
+
+ }
+
+ EPUser buildEpUser() {
+ EPUser epUser = new EPUser();
+
+ epUser.setId((long) 1);
+ epUser.setManagerId((long) 1234);
+ epUser.setFirstName(TEST);
+ epUser.setLastName(TEST);
+ epUser.setMiddleInitial(TEST);
+ epUser.setPhone(TEST);
+ epUser.setFax(TEST);
+ epUser.setCellular(TEST);
+ epUser.setEmail(TEST);
+ epUser.setAddressId((long) 123);
+ epUser.setAlertMethodCd(TEST);
+ epUser.setHrid(TEST);
+ epUser.setOrgUserId(TEST);
+ epUser.setOrgCode(TEST);
+ epUser.setAddress1(TEST);
+ epUser.setAddress2(TEST);
+ epUser.setCity(TEST);
+ epUser.setState(TEST);
+ epUser.setZipCode(TEST);
+ epUser.setCountry(TEST);
+ epUser.setOrgManagerUserId(TEST);
+ epUser.setLocationClli(TEST);
+ epUser.setBusinessCountryCode(TEST);
+ epUser.setBusinessCountryName(TEST);
+ epUser.setBusinessUnit(TEST);
+ epUser.setBusinessUnitName(TEST);
+ epUser.setDepartment(TEST);
+ epUser.setDepartmentName(TEST);
+ epUser.setCompanyCode(TEST);
+ epUser.setCompany(TEST);
+ epUser.setZipCodeSuffix(TEST);
+ epUser.setJobTitle(TEST);
+ epUser.setCommandChain(TEST);
+ epUser.setSiloStatus(TEST);
+ epUser.setCostCenter(TEST);
+ epUser.setFinancialLocCode(TEST);
+ epUser.setLoginId(TEST);
+ epUser.setLoginPwd(TEST);
+ epUser.setLastLoginDate(new Date());
+ epUser.setActive(false);
+ epUser.setInternal(false);
+ epUser.setSelectedProfileId((long) 12345);
+ epUser.setTimeZoneId((long) 12345);
+ epUser.setOnline(false);
+ epUser.setChatId(TEST);
+ return epUser;
+ }
}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralAppTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralAppTest.java
index e1e75b59..c56fa46c 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralAppTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralAppTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -48,9 +48,10 @@ public class CentralAppTest {
CentralApp centralApp=new CentralApp();
+ private static final String TEST="test";
public CentralApp mockCentralApp(){
- CentralApp centralApp = new CentralApp((long)1, null, null, (long)1, (long)1, (long)1, "test", "test", "test", "test", "test", "test", "test", "test", "test",
- "test", "test", "test", "test", null, "test", "test", "test", "test");
+ CentralApp centralApp = new CentralApp((long)1, null, null, (long)1, (long)1, (long)1, TEST, TEST, TEST, TEST, TEST, TEST, TEST, TEST, TEST,
+ TEST, TEST, TEST, TEST, null, TEST, TEST, TEST, TEST);
return centralApp;
}
@@ -58,35 +59,69 @@ public class CentralAppTest {
public void centralAppTest(){
CentralApp centralApp = mockCentralApp();
- CentralApp centralApp1 = new CentralApp((long)1, null, null, (long)1, (long)1, (long)1, "test", "test", "test", "test", "test", "test", "test", "test", "test",
- "test", "test", "test", "test", null, "test", "test", "test", "test");
+ CentralApp centralApp1 = buildCentralApp();
assertEquals(centralApp.getId(), new Long(1));
assertEquals(centralApp.getCreatedId(), new Long(1));
assertEquals(centralApp.getModifiedId(), new Long(1));
assertEquals(centralApp.getRowNum(), new Long(1));
- assertEquals(centralApp.getName(), "test");
- assertEquals(centralApp.getImageUrl(), "test");
- assertEquals(centralApp.getDescription(), "test");
- assertEquals(centralApp.getNotes(), "test");
- assertEquals(centralApp.getUrl(), "test");
- assertEquals(centralApp.getAlternateUrl(), "test");
- assertEquals(centralApp.getRestEndpoint(), "test");
- assertEquals(centralApp.getMlAppName(), "test");
- assertEquals(centralApp.getMlAppAdminId(), "test");
- assertEquals(centralApp.getMotsId(), "test");
- assertEquals(centralApp.getAppPassword(), "test");
- assertEquals(centralApp.getOpen(), "test");
- assertEquals(centralApp.getEnabled(), "test");
- assertEquals(centralApp.getUsername(), "test");
- assertEquals(centralApp.getUebKey(), "test");
- assertEquals(centralApp.getUebSecret(), "test");
- assertEquals(centralApp.getUebTopicName(), "test");
+ assertEquals(centralApp.getName(), TEST);
+ assertEquals(centralApp.getImageUrl(), TEST);
+ assertEquals(centralApp.getDescription(), TEST);
+ assertEquals(centralApp.getNotes(), TEST);
+ assertEquals(centralApp.getUrl(), TEST);
+ assertEquals(centralApp.getAlternateUrl(), TEST);
+ assertEquals(centralApp.getRestEndpoint(), TEST);
+ assertEquals(centralApp.getMlAppName(), TEST);
+ assertEquals(centralApp.getMlAppAdminId(), TEST);
+ assertEquals(centralApp.getMotsId(), TEST);
+ assertEquals(centralApp.getAppPassword(), TEST);
+ assertEquals(centralApp.getOpen(), TEST);
+ assertEquals(centralApp.getEnabled(), TEST);
+ assertEquals(centralApp.getUsername(), TEST);
+ assertEquals(centralApp.getUebKey(), TEST);
+ assertEquals(centralApp.getUebSecret(), TEST);
+ assertEquals(centralApp.getUebTopicName(), TEST);
assertTrue(centralApp.equals(centralApp1));
assertEquals(centralApp.hashCode(), centralApp1.hashCode());
}
+ private CentralApp buildCentralApp() {
+ CentralApp centralApp = new CentralApp();
+ centralApp.setId(1l);
+ centralApp.setCreatedId(1l);
+ centralApp.setModifiedId(1l);
+ centralApp.setRowNum(1l);
+ centralApp.setName(TEST);
+ centralApp.setImageUrl(TEST);
+ centralApp.setDescription(TEST);
+ centralApp.setNotes(TEST);
+ centralApp.setUrl(TEST);
+ centralApp.setAlternateUrl(TEST);
+ centralApp.setRestEndpoint(TEST);
+ centralApp.setMlAppAdminId(TEST);
+ centralApp.setMlAppName(TEST);
+ centralApp.setMotsId(TEST);
+ centralApp.setAppPassword(TEST);
+ centralApp.setOpen(TEST);
+ centralApp.setEnabled(TEST);
+ centralApp.setUsername(TEST);
+ centralApp.setUebKey(TEST);
+ centralApp.setUebSecret(TEST);
+ centralApp.setUebTopicName(TEST);
+
+
+
+
+
+
+
+
+ return centralApp;
+
+ }
+
@Test
public void unt_IdTest(){
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralRoleFunctionTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralRoleFunctionTest.java
new file mode 100644
index 00000000..26c2fcf9
--- /dev/null
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralRoleFunctionTest.java
@@ -0,0 +1,94 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalapp.portal.transport;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import java.util.Date;
+
+import org.junit.Test;
+
+public class CentralRoleFunctionTest {
+
+
+ private static final String TEST="test";
+ private static final Long ID=1l;
+ private static final Date DATE=new Date();
+
+ @Test
+ public void testCentralFunction() {
+ CentralRoleFunction centralRoleFunction=buildCentralRoleFunction();
+ CentralRoleFunction crf=new CentralRoleFunction(TEST,TEST);
+ crf.setId(centralRoleFunction.getId());
+ crf.setCreated(centralRoleFunction.getCreated());
+ crf.setModified(centralRoleFunction.getModified());
+ crf.setCreatedId(centralRoleFunction.getCreatedId());
+ crf.setModifiedId(centralRoleFunction.getModifiedId());
+ crf.setAuditTrail(centralRoleFunction.getAuditTrail());
+ crf.setAuditUserId(centralRoleFunction.getAuditUserId());
+ crf.setRowNum(centralRoleFunction.getRowNum());
+ crf.setCode(centralRoleFunction.getCode());
+ crf.setName(centralRoleFunction.getName());
+ crf.setEditUrl(centralRoleFunction.getEditUrl());
+
+ assertEquals(centralRoleFunction.hashCode(), crf.hashCode());
+ assertTrue(centralRoleFunction.equals(crf));
+ centralRoleFunction.compareTo(crf);
+
+
+ }
+
+
+ private CentralRoleFunction buildCentralRoleFunction() {
+
+ CentralRoleFunction crf=new CentralRoleFunction();
+ crf.setId(ID);
+ crf.setCreated(DATE);
+ crf.setModified(DATE);
+ crf.setCreatedId(ID);
+ crf.setModifiedId(ID);
+ crf.setAuditTrail(null);
+ crf.setAuditUserId(TEST);
+ crf.setRowNum(ID);
+ crf.setCode(TEST);
+ crf.setName(TEST);
+ crf.setEditUrl(TEST);
+ return crf;
+ }
+
+}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralUserAppTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralUserAppTest.java
index 5500b6a3..cf9abf12 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralUserAppTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralUserAppTest.java
@@ -38,6 +38,7 @@
package org.onap.portalapp.portal.transport;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
@@ -46,12 +47,51 @@ import org.onap.portalapp.portal.transport.CentralV2Role;
import org.onap.portalapp.portal.transport.CentralV2UserApp;
public class CentralUserAppTest {
+
+ private static final Long ID=1l;
+ private static final String TEST="test";
+
+ private CentralUserApp buildCentralUserApp() {
+ CentralUserApp app=new CentralUserApp();
+ app.setUserId(ID);
+ app.setPriority((short)1);
+ CentralApp centralApp=new CentralApp();
+ centralApp.setName(TEST);
+ CentralRole role=new CentralRole();
+ role.setName(TEST);
+ app.setApp(centralApp);
+ app.setRole(role);
+
+ return app;
+ }
+
+
+ @Test
+ public void test() {
+ CentralUserApp app1=buildCentralUserApp();
+ CentralUserApp app=new CentralUserApp();
+ app.setApp(app1.getApp());
+ app.setPriority(app1.getPriority());
+ app.setRole(app1.getRole());
+ app.setUserId(app1.getUserId());
+ assertEquals(app.hashCode(), app1.hashCode());
+ app.compareTo(app1);
+ assertTrue(app.equals(app1));
+ assertFalse(app.equals(null));
+ app.setRole(null);
+ assertFalse(app.equals(app1));
+ app.setRole(app1.getRole());
+ app.getRole().setName("test2");
+
+ assertTrue(app.equals(app1));
+
+ }
public CentralV2UserApp mockCentralUserApp(){
CentralV2UserApp centralV2UserApp = new CentralV2UserApp();
- CentralApp app = new CentralApp((long)1, null, null, (long)1, (long)1, (long)1, "test", "test", "test", "test", "test", "test", "test", "test", "test",
- "test", "test", "test", "test", null, "test", "test", "test", "test");
+ CentralApp app = new CentralApp((long)1, null, null,ID,ID,ID, TEST, TEST, TEST, TEST, TEST, TEST, TEST, TEST, TEST,
+ TEST, TEST, TEST, TEST, null, TEST, TEST, TEST, TEST);
CentralV2Role role = new CentralV2Role();
@@ -63,12 +103,14 @@ public class CentralUserAppTest {
return centralV2UserApp;
}
+
+
@Test
public void centralUserAppTest(){
CentralV2UserApp centralV2UserApp = mockCentralUserApp();
- CentralApp app1 = new CentralApp((long)1, null, null, (long)1, (long)1, (long)1, "test", "test", "test", "test", "test", "test", "test", "test", "test",
- "test", "test", "test", "test", null, "test", "test", "test", "test");
+ CentralApp app1 = new CentralApp((long)1, null, null,ID,ID,ID, TEST, TEST, TEST, TEST, TEST, TEST, TEST, TEST, TEST,
+ TEST, TEST, TEST, TEST, null, TEST, TEST, TEST, TEST);
CentralV2Role role1 = new CentralV2Role();
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralV2UserTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralV2UserTest.java
new file mode 100644
index 00000000..0f7da0a1
--- /dev/null
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/CentralV2UserTest.java
@@ -0,0 +1,267 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalapp.portal.transport;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.junit.Test;
+
+public class CentralV2UserTest {
+
+ private static final String TEST="test";
+ private static final Long ID=1l;
+ private static final Date DATE=new Date();
+
+
+ @Test
+ public void testCentralUser() {
+
+
+ CentralV2User user=buildV2User();
+ user.setZipCodeSuffix(TEST);
+ CentralV2User centrlUser=new CentralV2User();
+ centrlUser.setId(user.getId());
+ centrlUser.setCreated(user.getCreated());
+ centrlUser.setModified(user.getModified());
+ centrlUser.setCreatedId(user.getCreatedId());
+ centrlUser.setModifiedId(user.getModifiedId());
+ centrlUser.setRowNum(user.getRowNum());
+ centrlUser.setOrgId(user.getOrgId());
+ centrlUser.setManagerId(user.getManagerId());
+ centrlUser.setFirstName(user.getFirstName());
+ centrlUser.setMiddleInitial(user.getMiddleInitial());
+ centrlUser.setLastName(user.getLastName());
+ centrlUser.setPhone(user.getPhone());
+ centrlUser.setFax(user.getFax());
+ centrlUser.setCellular(user.getCellular());
+ centrlUser.setEmail(user.getEmail());
+ centrlUser.setAddressId(user.getAddressId());
+ centrlUser.setAlertMethodCd(user.getAlertMethodCd());
+ centrlUser.setHrid(user.getHrid());
+ centrlUser.setOrgUserId(user.getOrgUserId());
+ centrlUser.setOrgCode(user.getOrgCode());
+ centrlUser.setAddress1(user.getAddress1());
+ centrlUser.setAddress2(user.getAddress2());
+ centrlUser.setCity(user.getCity());
+ centrlUser.setState(user.getState());
+ centrlUser.setZipCode(user.getZipCode());
+ centrlUser.setCountry(user.getCountry());
+
+ centrlUser.setOrgManagerUserId(user.getOrgManagerUserId());
+ centrlUser.setLocationClli(user.getLocationClli());
+ centrlUser.setBusinessCountryCode(user.getBusinessCountryCode());
+ centrlUser.setBusinessCountryName(user.getBusinessCountryName());
+ centrlUser.setBusinessUnit(user.getBusinessUnit());
+ centrlUser.setBusinessUnitName(user.getBusinessUnitName());
+ centrlUser.setDepartment(user.getDepartment());
+ centrlUser.setDepartmentName(user.getDepartmentName());
+ centrlUser.setCompanyCode(user.getCompanyCode());
+ centrlUser.setCompany(user.getCompany());
+ centrlUser.setZipCode(user.getZipCode());
+ centrlUser.setZipCodeSuffix(user.getZipCodeSuffix());
+ centrlUser.setJobTitle(user.getJobTitle());
+ centrlUser.setCommandChain(user.getCommandChain());
+ centrlUser.setSiloStatus(user.getSiloStatus());
+ centrlUser.setCostCenter(user.getCostCenter());
+ centrlUser.setFinancialLocCode(user.getFinancialLocCode());
+ centrlUser.setLoginId(user.getLoginId());
+ centrlUser.setLoginPwd(user.getLoginPwd());
+ centrlUser.setLastLoginDate(user.getLastLoginDate());
+ centrlUser.setActive(user.isActive());
+ centrlUser.setInternal(user.isInternal());
+ centrlUser.setSelectedProfileId(user.getSelectedProfileId());
+ centrlUser.setTimeZoneId(user.getTimeZoneId());
+ centrlUser.setOnline(user.isOnline());
+ centrlUser.setChatId(user.getChatId());
+ centrlUser.setUserApps(user.getUserApps());
+ centrlUser.setPseudoRoles(user.getPseudoRoles());
+
+ assertEquals(user.hashCode(), centrlUser.hashCode());
+ assertTrue(centrlUser.equals(centrlUser));
+ assertFalse(user.equals(null));
+ assertEquals(ID, user.getId());
+ assertEquals(DATE, user.getCreated());
+ assertEquals(DATE, user.getModified());
+
+ centrlUser.setZipCodeSuffix(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setZipCode(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setUserApps(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setTimeZoneId(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setState(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setSiloStatus(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setSelectedProfileId(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setRowNum(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setPseudoRoles(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setPhone(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setOrgUserId(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setOrgManagerUserId(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setOrgId(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setOrgCode(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setOnline(false);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setModifiedId(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setModified(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setMiddleInitial(null);
+ assertFalse(centrlUser.equals(user));
+
+ centrlUser.setManagerId(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setLoginPwd(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setLoginId(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setLocationClli(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setLastName(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setLastLoginDate(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setJobTitle(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setInternal(false);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setId(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setHrid(null);
+ assertFalse(centrlUser.equals(user));
+
+ centrlUser.setFirstName(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setFinancialLocCode(null);
+ assertFalse(centrlUser.equals(user));
+
+ centrlUser.setFax(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setEmail(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setDepartmentName(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setDepartment(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setCreatedId(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setCreated(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setCountry(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setCostCenter(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setCompanyCode(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setCompany(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setCommandChain(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setCity(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setChatId(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setCellular(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setBusinessUnitName(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setBusinessUnit(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setBusinessCountryName(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setBusinessCountryCode(null);
+ assertFalse(centrlUser.equals(user));
+
+ centrlUser.setBusinessCountryCode(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setAlertMethodCd(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setAddressId(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setAddress2(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setAddress1(null);
+ assertFalse(centrlUser.equals(user));
+ centrlUser.setActive(false);
+ assertFalse(centrlUser.equals(user));
+
+ centrlUser.hashCode();
+
+
+
+
+
+ }
+
+ public CentralV2User buildV2User(){
+ Set<CentralV2UserApp> userApps = new HashSet<CentralV2UserApp>();
+ Set<CentralV2Role> pseudoRoles = new HashSet<CentralV2Role>();
+ CentralV2User centralV2User = new CentralV2User(ID, DATE, DATE, ID, ID, ID, ID,
+ ID, TEST, TEST, TEST, TEST, TEST,
+ TEST, TEST, ID, TEST, TEST, TEST,
+ TEST, TEST, TEST, TEST, TEST, TEST, TEST,
+ TEST, TEST, TEST, TEST,
+ TEST, TEST, TEST, TEST, TEST,
+ TEST, TEST, TEST, TEST, TEST,
+ TEST, TEST, TEST, TEST, null,
+ false, false, ID, ID, false, TEST, userApps, pseudoRoles);
+
+ return centralV2User;
+ }
+
+
+
+}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/EPUserAppCurrentRolesTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/EPUserAppCurrentRolesTest.java
index 5fe68ee7..98ae0f07 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/EPUserAppCurrentRolesTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/EPUserAppCurrentRolesTest.java
@@ -38,6 +38,7 @@
package org.onap.portalapp.portal.transport;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
@@ -45,34 +46,42 @@ import org.onap.portalapp.portal.transport.EPUserAppCurrentRoles;
public class EPUserAppCurrentRolesTest {
- public EPUserAppCurrentRoles mockEPUserAppCurrentRoles(){
+ private static final String TEST="test";
+ private static final Long ID=1l;
+ private EPUserAppCurrentRoles mockEPUserAppCurrentRoles(){
EPUserAppCurrentRoles epUserAppCurrentRoles = new EPUserAppCurrentRoles();
- epUserAppCurrentRoles.setRoleName("test");
- epUserAppCurrentRoles.setUserId((long)1);
- epUserAppCurrentRoles.setPriority("test");
- epUserAppCurrentRoles.setRoleId((long)1);
+ epUserAppCurrentRoles.setRoleName(TEST);
+ epUserAppCurrentRoles.setUserId(ID);
+ epUserAppCurrentRoles.setPriority(TEST);
+ epUserAppCurrentRoles.setRoleId(ID);
return epUserAppCurrentRoles;
}
+
@Test
public void epUserAppCurrentRolesTest(){
EPUserAppCurrentRoles epUserAppCurrentRoles = mockEPUserAppCurrentRoles();
EPUserAppCurrentRoles epUserAppCurrentRoles1 = new EPUserAppCurrentRoles();
- epUserAppCurrentRoles1.setRoleName("test");
- epUserAppCurrentRoles1.setUserId((long)1);
- epUserAppCurrentRoles1.setPriority("test");
- epUserAppCurrentRoles1.setRoleId((long)1);
+ epUserAppCurrentRoles1.setRoleName(epUserAppCurrentRoles.getRoleName());
+ epUserAppCurrentRoles1.setUserId(epUserAppCurrentRoles.getUserId());
+ epUserAppCurrentRoles1.setPriority(epUserAppCurrentRoles.getPriority());
+ epUserAppCurrentRoles1.setRoleId(epUserAppCurrentRoles.getRoleId());
- assertEquals(epUserAppCurrentRoles.getRoleName(), "test");
- assertEquals(epUserAppCurrentRoles.getUserId(), new Long(1));
- assertEquals(epUserAppCurrentRoles.getRoleId(), new Long(1));
- assertEquals(epUserAppCurrentRoles.getPriority(), "test");
assertEquals(epUserAppCurrentRoles.hashCode(), epUserAppCurrentRoles1.hashCode());
assertTrue(epUserAppCurrentRoles.equals(epUserAppCurrentRoles1));
+ assertFalse(epUserAppCurrentRoles1.equals(null));
+ epUserAppCurrentRoles1.setUserId(null);
+ assertFalse(epUserAppCurrentRoles1.equals(epUserAppCurrentRoles));
+ epUserAppCurrentRoles1.setRoleName(null);
+ assertFalse(epUserAppCurrentRoles1.equals(epUserAppCurrentRoles));
+ epUserAppCurrentRoles1.setRoleId(null);
+ assertFalse(epUserAppCurrentRoles1.equals(epUserAppCurrentRoles));
+ epUserAppCurrentRoles1.setPriority(null);
+ assertFalse(epUserAppCurrentRoles1.equals(epUserAppCurrentRoles));
}
}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/EcompUserRolesTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/EcompUserRolesTest.java
new file mode 100644
index 00000000..aec41d94
--- /dev/null
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/EcompUserRolesTest.java
@@ -0,0 +1,112 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalapp.portal.transport;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Date;
+
+import org.junit.Test;
+
+public class EcompUserRolesTest {
+ private static final String TEST="test";
+ private static final Long ID=1l;
+ private static final Date DATE=new Date();
+
+ @Test
+ public void testUserRole() {
+
+ EcompUserRoles userRole=buildEcompUserRole();
+ assertEquals(TEST, userRole.getManagerId());
+ assertEquals(TEST, userRole.getFirstName());
+
+ assertEquals(TEST, userRole.getMiddleInitial());
+ assertEquals(TEST, userRole.getLastName());
+
+ assertEquals(ID, userRole.getOrgId());
+ assertEquals(TEST, userRole.getPhone());
+ assertEquals(TEST, userRole.getFunctionCode());
+ assertEquals(TEST, userRole.getFunctionName());
+ assertEquals(TEST, userRole.getOrgManagerUserId());
+ assertEquals(TEST, userRole.getOrgUserId());
+ assertEquals(TEST, userRole.getOrgCode());
+ assertEquals(TEST, userRole.getJobTitle());
+ assertEquals(TEST, userRole.getLoginId());
+ assertEquals(TEST, userRole.getEmail());
+ assertEquals(TEST, userRole.getHrid());
+ assertEquals(true, userRole.isActive());
+ assertEquals(TEST, userRole.getRoleName());
+ assertEquals(ID, userRole.getRoleId());
+
+ assertNotNull(userRole.toString());
+
+ }
+
+
+
+ private EcompUserRoles buildEcompUserRole() {
+
+ EcompUserRoles userRole=new EcompUserRoles();
+
+ userRole.setOrgId(ID);
+ userRole.setManagerId(TEST);
+ userRole.setFirstName(TEST);
+ userRole.setMiddleInitial(TEST);
+ userRole.setLastName(TEST);
+ userRole.setPhone(TEST);
+ userRole.setOrgManagerUserId(TEST);
+ userRole.setOrgCode(TEST);
+ userRole.setJobTitle(TEST);
+ userRole.setLoginId(TEST);
+ userRole.setFunctionCode(TEST);
+ userRole.setFunctionName(TEST);
+ userRole.setEmail(TEST);
+ userRole.setHrid(TEST);
+ userRole.setOrgUserId(TEST);
+ userRole.setHrid(TEST);
+ userRole.setActive(true);
+ userRole.setRoleId(ID);
+ userRole.setRoleName(TEST);
+
+
+ return userRole;
+ }
+
+
+}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/EpNotificationItemTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/EpNotificationItemTest.java
index 9af91a5a..9ae4aadb 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/EpNotificationItemTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/EpNotificationItemTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -36,63 +36,119 @@
*
*/package org.onap.portalapp.portal.transport;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
import org.junit.Test;
-import org.onap.portalapp.portal.transport.EpNotificationItem;
public class EpNotificationItemTest {
+ private static final String TEST="test";
+ private static Date date=new Date();
+
public EpNotificationItem mockEpNotificationItem(){
EpNotificationItem epNotificationItem = new EpNotificationItem();
-
+ Set<EpRoleNotificationItem> list=new HashSet<>();
+ EpRoleNotificationItem item=new EpRoleNotificationItem();
+ item.setRoleId(3);
+ item.setId(1l);
+ list.add(item);
+ List<Long> roleIds= list.stream().map(e->e.getId()).collect(Collectors.toList());
epNotificationItem.setNotificationId((long)1);
- epNotificationItem.setIsForOnlineUsers("test");
- epNotificationItem.setIsForAllRoles("test");
- epNotificationItem.setActiveYn("test");
- epNotificationItem.setMsgHeader("test");
- epNotificationItem.setMsgDescription("test");
- epNotificationItem.setMsgSource("test");
+ epNotificationItem.setIsForOnlineUsers(TEST);
+ epNotificationItem.setIsForAllRoles(TEST);
+ epNotificationItem.setActiveYn(TEST);
+ epNotificationItem.setMsgHeader(TEST);
+ epNotificationItem.setMsgDescription(TEST);
+ epNotificationItem.setMsgSource(TEST);
epNotificationItem.setPriority((long)1);
epNotificationItem.setCreatedId((long)1);
- epNotificationItem.setNotificationHyperlink("test");
+ epNotificationItem.setNotificationHyperlink(TEST);
+ epNotificationItem.setStartTime(date);
+ epNotificationItem.setEndTime(date);
+ epNotificationItem.setCreatedDate(date);
+ epNotificationItem.setCreatorId(1l);
+ epNotificationItem.setRoles(list);
+ epNotificationItem.setRoleIds(roleIds);
+
return epNotificationItem;
}
+
+
@Test
public void epNotificationItemTest(){
- EpNotificationItem epNotificationItem = mockEpNotificationItem();
-
- EpNotificationItem epNotificationItem1 = new EpNotificationItem();
- epNotificationItem1.setNotificationId((long)1);
- epNotificationItem1.setIsForOnlineUsers("test");
- epNotificationItem1.setIsForAllRoles("test");
- epNotificationItem1.setActiveYn("test");
- epNotificationItem1.setMsgHeader("test");
- epNotificationItem1.setMsgDescription("test");
- epNotificationItem1.setMsgSource("test");
+ EpNotificationItem epNotificationItem1 = mockEpNotificationItem();
- epNotificationItem1.setPriority((long)1);
- epNotificationItem1.setCreatedId((long)1);
- epNotificationItem1.setNotificationHyperlink("test");
-
- assertEquals(epNotificationItem.getNotificationId(), new Long(1));
- assertEquals(epNotificationItem.getIsForOnlineUsers(), "test");
- assertEquals(epNotificationItem.getIsForAllRoles(), "test");
- assertEquals(epNotificationItem.getActiveYn(), "test");
- assertEquals(epNotificationItem.getMsgHeader(), "test");
- assertEquals(epNotificationItem.getMsgDescription(), "test");
- assertEquals(epNotificationItem.getMsgSource(), "test");
- assertEquals(epNotificationItem.getPriority(), new Long(1));
- assertEquals(epNotificationItem.getCreatedId(), new Long(1));
- assertEquals(epNotificationItem.getNotificationHyperlink(), "test");
-
- assertEquals(epNotificationItem.toString(), "EpNotificationItem [notificationId=1, isForOnlineUsers=test, isForAllRoles=test, activeYn=test, msgHeader=test, msgDescription=test, msgSource=test, startTime=null, endTime=null, priority=1, creatorId=null, createdDate=null, roles=null, roleIds=null]");
+ EpNotificationItem epNotificationItem = new EpNotificationItem();
+ epNotificationItem.setNotificationId(epNotificationItem1.getNotificationId());
+ epNotificationItem.setIsForOnlineUsers(epNotificationItem1.getIsForOnlineUsers());
+ epNotificationItem.setIsForAllRoles(epNotificationItem1.getIsForAllRoles());
+ epNotificationItem.setActiveYn(epNotificationItem1.getActiveYn());
+ epNotificationItem.setMsgHeader(epNotificationItem1.getMsgHeader());
+ epNotificationItem.setMsgDescription(epNotificationItem1.getMsgDescription());
+ epNotificationItem.setMsgSource(epNotificationItem1.getMsgSource());
+
+ epNotificationItem.setPriority((long)1);
+ epNotificationItem.setCreatedId(epNotificationItem1.getCreatedId());
+ epNotificationItem.setNotificationHyperlink(epNotificationItem1.getNotificationHyperlink());
+ epNotificationItem.setStartTime(new Date());
+ epNotificationItem.setEndTime(epNotificationItem1.getEndTime());
+ epNotificationItem.setCreatedDate(epNotificationItem1.getCreatedDate());
+ epNotificationItem.setCreatorId(epNotificationItem1.getCreatorId());
+ epNotificationItem.setRoles(epNotificationItem1.getRoles());
+ epNotificationItem.setRoleIds(epNotificationItem1.getRoleIds());
+ epNotificationItem.setStartTime(epNotificationItem1.getStartTime());
+ assertNotNull(epNotificationItem.toString());
+ //assertNotEquals(epNotificationItem.toString(), "EpNotificationItem [notificationId=1, isForOnlineUsers=test, isForAllRoles=test, activeYn=test, msgHeader=test, msgDescription=test, msgSource=test, startTime=null, endTime=null, priority=1, creatorId=null, createdDate=null, roles=null, roleIds=null]");
assertEquals(epNotificationItem.hashCode(), epNotificationItem1.hashCode());
+ EpNotificationItem epNotificationItem2 =epNotificationItem;
+ assertTrue(epNotificationItem.equals(epNotificationItem2));
assertTrue(epNotificationItem.equals(epNotificationItem1));
-
+
+ assertTrue(epNotificationItem.equals(epNotificationItem1));
+ assertFalse(epNotificationItem.equals(null));
+ epNotificationItem.setStartTime(null);
+ assertFalse(epNotificationItem.equals(epNotificationItem1));
+ epNotificationItem.setRoles(null);
+ assertFalse(epNotificationItem.equals(epNotificationItem1));
+ epNotificationItem.setRoleIds(null);
+ assertFalse(epNotificationItem.equals(epNotificationItem1));
+ epNotificationItem.setPriority(null);
+ assertFalse(epNotificationItem.equals(epNotificationItem1));
+ epNotificationItem.setNotificationId(null);
+ assertFalse(epNotificationItem.equals(epNotificationItem1));
+ epNotificationItem.setMsgSource(null);
+ assertFalse(epNotificationItem.equals(epNotificationItem1));
+ epNotificationItem.setMsgHeader(null);
+ assertFalse(epNotificationItem.equals(epNotificationItem1));
+ epNotificationItem.setMsgDescription(null);
+ assertFalse(epNotificationItem.equals(epNotificationItem1));
+ epNotificationItem.setIsForOnlineUsers(null);
+ assertFalse(epNotificationItem.equals(epNotificationItem1));
+ epNotificationItem.setIsForAllRoles(null);
+ assertFalse(epNotificationItem.equals(epNotificationItem1));
+ epNotificationItem.setEndTime(null);
+ assertFalse(epNotificationItem.equals(epNotificationItem1));
+ epNotificationItem.setCreatedId(null);
+ assertFalse(epNotificationItem.equals(epNotificationItem1));
+ epNotificationItem.setCreatedDate(null);
+ assertFalse(epNotificationItem.equals(epNotificationItem1));
+ epNotificationItem.setActiveYn(null);
+ assertFalse(epNotificationItem.equals(epNotificationItem1));
+
+
}
}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/EpNotificationItemVOTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/EpNotificationItemVOTest.java
index 7c86ee15..494a8ce6 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/EpNotificationItemVOTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/EpNotificationItemVOTest.java
@@ -37,47 +37,81 @@
*/
package org.onap.portalapp.portal.transport;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.junit.Test;
-import org.onap.portalapp.portal.transport.EpNotificationItemVO;
public class EpNotificationItemVOTest {
+
+ private static final String TEST="test";
+ private static final Integer ID=1;
+ private static final Long EP_ID=1l;
+ private static final Date DATE=new Date();
+ private static final Character CHARACTER='a';
public EpNotificationItemVO mockEpNotificationItemVO(){
EpNotificationItemVO epNotificationItemVO = new EpNotificationItemVO();
- epNotificationItemVO.setNotificationId(1);
- epNotificationItemVO.setIsForOnlineUsers('a');
- epNotificationItemVO.setIsForAllRoles('a');
- epNotificationItemVO.setActiveYn('a');
- epNotificationItemVO.setMsgHeader("test");
- epNotificationItemVO.setMsgDescription("test");
- epNotificationItemVO.setMsgSource("test");
+ epNotificationItemVO.setNotificationId(ID);
+ epNotificationItemVO.setIsForOnlineUsers(CHARACTER);
+ epNotificationItemVO.setIsForAllRoles(CHARACTER);
+ epNotificationItemVO.setActiveYn(CHARACTER);
+ epNotificationItemVO.setMsgHeader(TEST);
+ epNotificationItemVO.setMsgDescription(TEST);
+ epNotificationItemVO.setMsgSource(TEST);
+ epNotificationItemVO.setStartTime(DATE);
+ epNotificationItemVO.setEndTime(DATE);
epNotificationItemVO.setPriority(1);
epNotificationItemVO.setCreatorId(1);
- epNotificationItemVO.setLoginId("test");
- epNotificationItemVO.setNotificationHyperlink("test");
+ epNotificationItemVO.setCreatedDate(DATE);
+ epNotificationItemVO.setLoginId(TEST);
+ epNotificationItemVO.setNotificationHyperlink(TEST);
+ epNotificationItemVO.setId(EP_ID);
+ epNotificationItemVO.setCreated(DATE);
+ epNotificationItemVO.setModified(DATE);
+ epNotificationItemVO.setCreatedId(EP_ID);
+ epNotificationItemVO.setModifiedId(EP_ID);
+ epNotificationItemVO.setRowNum(EP_ID);
+
+ epNotificationItemVO.setAuditUserId(EP_ID);
+ epNotificationItemVO.setAuditTrail(null);
+
return epNotificationItemVO;
}
@Test
public void epNotificationItemVOTest(){
- EpNotificationItemVO epNotificationItemVO = mockEpNotificationItemVO();
+ EpNotificationItemVO epNotification = mockEpNotificationItemVO();
+
+ EpNotificationItemVO epNotificationItemVO =new EpNotificationItemVO();
+
+ epNotificationItemVO.setNotificationId(epNotification.getNotificationId());
+ epNotificationItemVO.setIsForOnlineUsers(epNotification.getIsForOnlineUsers());
+ epNotificationItemVO.setIsForAllRoles(epNotification.getIsForAllRoles());
+ epNotificationItemVO.setActiveYn(epNotification.getActiveYn());
+ epNotificationItemVO.setMsgHeader(epNotification.getMsgHeader());
+ epNotificationItemVO.setMsgDescription(epNotification.getMsgDescription());
+ epNotificationItemVO.setMsgSource(epNotification.getMsgSource());
+ epNotificationItemVO.setStartTime(epNotification.getStartTime());
+ epNotificationItemVO.setEndTime(epNotification.getEndTime());
+ epNotificationItemVO.setPriority(epNotification.getPriority());
+ epNotificationItemVO.setCreatorId(epNotification.getCreatorId());
+ epNotificationItemVO.setCreatedDate(epNotification.getCreatedDate());
+ epNotificationItemVO.setLoginId(epNotification.getLoginId());
+ epNotificationItemVO.setNotificationHyperlink(epNotification.getNotificationHyperlink());
+ epNotificationItemVO.setId(epNotification.getId());
+ epNotificationItemVO.setCreated(epNotification.getCreated());
+ epNotificationItemVO.setModified(epNotification.getModified());
+ epNotificationItemVO.setCreatedId(epNotification.getCreatedId());
+ epNotificationItemVO.setModifiedId(epNotification.getModifiedId());
+ epNotificationItemVO.setRowNum(epNotification.getRowNum());
+
+ epNotificationItemVO.setAuditUserId(epNotification.getAuditUserId());
+ epNotificationItemVO.setAuditTrail(epNotification.getAuditTrail());
+
- assertEquals(epNotificationItemVO.getNotificationId().toString(), "1");
- /*assertEquals(epNotificationItemVO.getIsForOnlineUsers(), 'a');
- assertEquals(epNotificationItemVO.getIsForAllRoles(), 'a');
- assertEquals(epNotificationItemVO.getActiveYn(), 'a');*/
- assertEquals(epNotificationItemVO.getMsgHeader(), "test");
- assertEquals(epNotificationItemVO.getMsgDescription(), "test");
- assertEquals(epNotificationItemVO.getMsgSource(), "test");
- assertEquals(epNotificationItemVO.getPriority().toString(), "1");
- assertEquals(epNotificationItemVO.getCreatorId().toString(), "1");
- assertEquals(epNotificationItemVO.getLoginId(), "test");
- assertEquals(epNotificationItemVO.getNotificationHyperlink(), "test");
}
}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/ExternalRoleDescriptionTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/ExternalRoleDescriptionTest.java
index 63d230f5..6a4b6cab 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/ExternalRoleDescriptionTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/ExternalRoleDescriptionTest.java
@@ -38,35 +38,64 @@
package org.onap.portalapp.portal.transport;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.onap.portalapp.portal.transport.ExternalRoleDescription;
public class ExternalRoleDescriptionTest {
- public ExternalRoleDescription mockExternalRoleDescription(){
+ private static final String TEST="test";
+
+ @Test
+ public void externalRoleDescriptionTest(){
+ ExternalRoleDescription extRole=mockExternalRoleDescription();
+
+ ExternalRoleDescription externalRoleDescription = new ExternalRoleDescription();
+ externalRoleDescription.setId(extRole.getId());
+ externalRoleDescription.setName(extRole.getName());
+ externalRoleDescription.setActive(extRole.getActive());
+ externalRoleDescription.setPriority(extRole.getPriority());
+ externalRoleDescription.setAppId(extRole.getAppId());
+ externalRoleDescription.setAppRoleId(extRole.getAppRoleId());
+
+ assertEquals(externalRoleDescription.getId(), TEST);
+ assertEquals(externalRoleDescription.getName(), TEST);
+ assertEquals(externalRoleDescription.getActive(), TEST);
+ assertEquals(externalRoleDescription.getPriority(), TEST);
+ assertEquals(externalRoleDescription.getAppId(), TEST);
+ assertEquals(externalRoleDescription.getAppRoleId(), TEST);
+ assertEquals(externalRoleDescription.hashCode(), extRole.hashCode());
+ assertTrue(externalRoleDescription.equals(extRole));
+
+ assertFalse(externalRoleDescription.equals(null));
+ externalRoleDescription.setPriority(null);
+ assertFalse(externalRoleDescription.equals(extRole));
+ externalRoleDescription.setName(null);
+ assertFalse(externalRoleDescription.equals(extRole));
+ externalRoleDescription.setId(null);
+ assertFalse(externalRoleDescription.equals(extRole));
+ externalRoleDescription.setAppRoleId(null);
+ assertFalse(externalRoleDescription.equals(extRole));
+ externalRoleDescription.setAppId(null);
+ assertFalse(externalRoleDescription.equals(extRole));
+ externalRoleDescription.setActive(null);
+ assertFalse(externalRoleDescription.equals(extRole));
+ }
+ private ExternalRoleDescription mockExternalRoleDescription(){
ExternalRoleDescription externalRoleDescription = new ExternalRoleDescription();
- externalRoleDescription.setId("test");
- externalRoleDescription.setName("test");
- externalRoleDescription.setActive("test");
- externalRoleDescription.setPriority("test");
- externalRoleDescription.setAppId("test");
- externalRoleDescription.setAppRoleId("test");
+ externalRoleDescription.setId(TEST);
+ externalRoleDescription.setName(TEST);
+ externalRoleDescription.setActive(TEST);
+ externalRoleDescription.setPriority(TEST);
+ externalRoleDescription.setAppId(TEST);
+ externalRoleDescription.setAppRoleId(TEST);
return externalRoleDescription;
}
- @Test
- public void externalRoleDescriptionTest(){
- ExternalRoleDescription externalRoleDescription = mockExternalRoleDescription();
-
- assertEquals(externalRoleDescription.getId(), "test");
- assertEquals(externalRoleDescription.getName(), "test");
- assertEquals(externalRoleDescription.getActive(), "test");
- assertEquals(externalRoleDescription.getPriority(), "test");
- assertEquals(externalRoleDescription.getAppId(), "test");
- assertEquals(externalRoleDescription.getAppRoleId(), "test");
- }
+
}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/FieldsValidatorTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/FieldsValidatorTest.java
new file mode 100644
index 00000000..b1baafa0
--- /dev/null
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/FieldsValidatorTest.java
@@ -0,0 +1,79 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalapp.portal.transport;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class FieldsValidatorTest {
+
+ private static final String TEST="test";
+
+ @Test
+ public void test() {
+ FieldsValidator fv=buildFieldsValidator();
+ FieldsValidator fieldsValidator=new FieldsValidator();
+ fieldsValidator.setErrorCode(fv.getErrorCode());
+ fieldsValidator.setHttpStatusCode(fv.getHttpStatusCode());
+ fieldsValidator.setFields(fv.getFields());
+ assertNotNull(fieldsValidator.toString());
+ assertEquals(fieldsValidator.hashCode(), fv.hashCode());
+ assertTrue(fieldsValidator.equals(fv));
+ assertFalse(fieldsValidator.equals(null));
+ fieldsValidator.setHttpStatusCode(null);
+ assertFalse(fieldsValidator.equals(fv));
+ fieldsValidator.setErrorCode(null);
+ assertFalse(fieldsValidator.equals(fv));
+
+
+ }
+
+ private FieldsValidator buildFieldsValidator() {
+ FieldsValidator fieldsValidator=new FieldsValidator();
+
+ fieldsValidator.addProblematicFieldName(TEST);
+ fieldsValidator.setErrorCode(1l);
+ fieldsValidator.setHttpStatusCode(200l);
+
+ return fieldsValidator;
+ }
+}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/FunctionalMenuItemTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/FunctionalMenuItemTest.java
index add12d09..4eced3b2 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/FunctionalMenuItemTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/FunctionalMenuItemTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -41,6 +41,7 @@ import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import org.junit.Test;
import org.onap.portalapp.portal.transport.FunctionalMenuItem;
@@ -51,29 +52,26 @@ public class FunctionalMenuItemTest {
FunctionalMenuItem functionalMenuItem = new FunctionalMenuItem();
List<Integer> roles = new ArrayList<Integer>();
+ roles.add(1);
functionalMenuItem.setRestrictedApp(false);
functionalMenuItem.setUrl("test");
functionalMenuItem.setRoles(roles);
+
return functionalMenuItem;
}
@Test
- public void functionalMenuItemTest(){
- FunctionalMenuItem functionalMenuItem = mockFunctionalMenuItem();
-
- FunctionalMenuItem functionalMenuItem1 = mockFunctionalMenuItem();
-
- List<Integer> roles = new ArrayList<Integer>();
-
- functionalMenuItem1.setRestrictedApp(false);
- functionalMenuItem1.setUrl("test");
- functionalMenuItem1.setRoles(roles);
-
- assertEquals(functionalMenuItem.getRoles(), functionalMenuItem1.getRoles());
- assertEquals(functionalMenuItem.toString(), "FunctionalMenuItem [menuId=null, column=null, text=null, parentMenuId=null, url=test, active_yn=null, appid=null, roles=[], restrictedApp=false]");
- // assertTrue(functionalMenuItem.normalize(), functionalMenuItem1.normalize());
+ public void functionalMenuItemTest_normalize() {
+ FunctionalMenuItem functionalMenu =mockFunctionalMenuItem();
+ FunctionalMenuItem functionalMenuItem = new FunctionalMenuItem();
+ functionalMenuItem.setRestrictedApp(false);
+ functionalMenuItem.setRoles(functionalMenu.getRoles());
+ functionalMenu.setUrl("test");
+ functionalMenuItem.normalize();
+ assertNotNull(functionalMenuItem.toString());
}
+
}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/RemoteRoleTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/RemoteRoleTest.java
index 11b979f3..664a91cf 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/RemoteRoleTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/RemoteRoleTest.java
@@ -39,44 +39,46 @@ package org.onap.portalapp.portal.transport;
//@RunWith(PowerMockRunner.class)
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import java.util.HashSet;
import java.util.Set;
-import org.junit.Before;
import org.junit.Test;
public class RemoteRoleTest {
- RemoteRole remoteRole;
+
private String NAME = "test";
private Long ID = 12L;
private Set<String> ROLEFUNCTIONS = new HashSet<String>();
- @Before
- public void setUp() {
- remoteRole = new RemoteRole();
+ @Test
+ public void test() {
+ RemoteRole rr=buildRemoteRole();
+ RemoteRole remoteRole = new RemoteRole();
+ remoteRole.setRoleFunctions(rr.getRoleFunctions());
+ remoteRole.setName(rr.getName());
+ remoteRole.setId(rr.getId());
+ assertNotNull(remoteRole.toString());
+ assertEquals(remoteRole.hashCode(), rr.hashCode());
+ assertTrue(remoteRole.equals(rr));
+ assertFalse(remoteRole.equals(null));
+ remoteRole.setName(null);
+ assertFalse(remoteRole.equals(rr));
+ remoteRole.setId(null);
+ assertFalse(remoteRole.equals(rr));
+ }
+
+ private RemoteRole buildRemoteRole() {
+ RemoteRole remoteRole = new RemoteRole();
remoteRole.setRoleFunctions(ROLEFUNCTIONS);
remoteRole.setName(NAME);
remoteRole.setId(ID);
+ return remoteRole;
}
- @Test
- public void testNotNull() {
- assertNotNull(remoteRole);
- }
-
- @Test
- public void testRemoteRoleProperties() {
- assertEquals(ROLEFUNCTIONS, remoteRole.getRoleFunctions());
- assertEquals(ID, remoteRole.getId());
- assertEquals(NAME, remoteRole.getName());
- }
-
- @Test
- public void testequals() {
- assertEquals(true, remoteRole.equals(remoteRole));
- }
} \ No newline at end of file
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/RemoteRoleV1Test.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/RemoteRoleV1Test.java
index 27652d30..ebd11753 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/RemoteRoleV1Test.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/RemoteRoleV1Test.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -39,6 +39,7 @@ package org.onap.portalapp.portal.transport;
//@RunWith(PowerMockRunner.class)
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -70,6 +71,36 @@ public class RemoteRoleV1Test {
}
@Test
+ public void testRemoteRole() {
+ RemoteRoleV1 remoteRoleV1=buildRemoteRoleV1();
+ RemoteRoleV1 remoteRole=new RemoteRoleV1();
+ RemoteRoleV1 remoteRoleV2=remoteRoleV1;
+ remoteRole.setId(ID);
+ remoteRole.setName(NAME);
+
+ assertEquals(remoteRole.hashCode(), remoteRoleV1.hashCode());
+ remoteRole.compareTo(remoteRoleV1);
+ assertTrue(remoteRole.equals(remoteRoleV1));
+ assertFalse(remoteRole.equals(null));
+ remoteRole.setName(null);
+ assertFalse(remoteRole.equals(remoteRoleV1));
+ remoteRole.setId(null);
+ assertFalse(remoteRole.equals(remoteRoleV1));
+ assertTrue(remoteRoleV2.equals(remoteRoleV1));
+
+ }
+
+ private RemoteRoleV1 buildRemoteRoleV1() {
+
+ RemoteRoleV1 remoteRole=new RemoteRoleV1();
+ remoteRole.setId(ID);
+ remoteRole.setName(NAME);
+ return remoteRole;
+ }
+
+
+
+ @Test
public void remoteRoleV1Test(){
RemoteRoleV1 remoteRoleV11 = new RemoteRoleV1();
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/UserWithNameSurnameTitleTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/UserWithNameSurnameTitleTest.java
index 22188e45..a21bde4a 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/UserWithNameSurnameTitleTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/transport/UserWithNameSurnameTitleTest.java
@@ -43,14 +43,33 @@ import org.junit.Test;
import org.onap.portalapp.portal.transport.UserWithNameSurnameTitle;
public class UserWithNameSurnameTitleTest {
+
+ private static final String TEST="test";
@Test
public void userWithNameSurnameTitleTest(){
- UserWithNameSurnameTitle userWithNameSurnameTitle = new UserWithNameSurnameTitle("test", "test", "test", "test");
+ UserWithNameSurnameTitle user=buildUserWithNameSurnameTitle();
- assertEquals(userWithNameSurnameTitle, new UserWithNameSurnameTitle("test", "test", "test", "test"));
- assertEquals(userWithNameSurnameTitle.hashCode(), new UserWithNameSurnameTitle("test", "test", "test", "test").hashCode());
- assertTrue(userWithNameSurnameTitle.equals(new UserWithNameSurnameTitle("test", "test", "test", "test")));
+ UserWithNameSurnameTitle userWithNameSurnameTitle = new UserWithNameSurnameTitle(TEST, TEST, TEST, TEST);
+ assertEquals(user.hashCode(), userWithNameSurnameTitle.hashCode());
+ assertTrue(user.equals(userWithNameSurnameTitle));
+ assertFalse(user.equals(null));
+ UserWithNameSurnameTitle userWithNameSurnameTitle1 = new UserWithNameSurnameTitle(null, TEST, TEST, TEST);
+ assertFalse(userWithNameSurnameTitle1.equals(user));
+ userWithNameSurnameTitle1 = new UserWithNameSurnameTitle(null, TEST, null, TEST);
+ assertFalse(userWithNameSurnameTitle1.equals(user));
+ userWithNameSurnameTitle1 = new UserWithNameSurnameTitle(null, TEST, null, null);
+ assertFalse(userWithNameSurnameTitle1.equals(user));
+ userWithNameSurnameTitle1 = new UserWithNameSurnameTitle(null, null, null, null);
+ assertFalse(userWithNameSurnameTitle1.equals(user));
+
+
+ }
+
+ private UserWithNameSurnameTitle buildUserWithNameSurnameTitle() {
+
+ UserWithNameSurnameTitle userWithNameSurnameTitle=new UserWithNameSurnameTitle(TEST, TEST, TEST, TEST);
+ return userWithNameSurnameTitle;
}
}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/utils/HashMapFromListTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/utils/HashMapFromListTest.java
new file mode 100644
index 00000000..0ed2aeca
--- /dev/null
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/utils/HashMapFromListTest.java
@@ -0,0 +1,155 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalapp.portal.utils;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.junit.Test;
+import org.onap.portalapp.portal.domain.EPUser;
+import org.onap.portalapp.portal.domain.EPUserAppRoles;
+
+public class HashMapFromListTest {
+
+ private static final String TEST="test";
+
+ @Test
+ public void testHashMap() {
+
+ List<String> data=new ArrayList<>();
+ data.add(TEST);
+
+ HashMapFromList<String> map=new HashMapFromList<>();
+ map.hashMap(data, TEST);
+
+ }
+
+ @Test
+ public void testHashMapUser() {
+
+ List<EPUser> data=new ArrayList<>();
+ data.add(buildUser());
+
+ HashMapFromList<EPUser> map=new HashMapFromList<>();
+ map.hashMap(data, "firstName");
+
+ }
+
+ @Test
+ public void testHashMapUserField() {
+
+ List<EPUserAppRoles> data=new ArrayList<>();
+ EPUserAppRoles role=new EPUserAppRoles();
+ role.setAppId(2l);
+ role.setRoleId(3l);
+ data.add(role);
+
+ HashMapFromList<EPUserAppRoles> map=new HashMapFromList<>();
+ map.hashMap(data, "appId");
+
+ }
+
+ @Test
+ public void testHashMapUserFieldException() {
+
+ List<EPUserAppRoles> data=new ArrayList<>();
+ EPUserAppRoles role=new EPUserAppRoles();
+ role.setAppId(null);
+ role.setRoleId(3l);
+ data.add(role);
+
+ HashMapFromList<EPUserAppRoles> map=new HashMapFromList<>();
+ map.hashMap(data, "appId");
+
+ }
+
+
+
+ private EPUser buildUser() {
+ EPUser epUser = new EPUser();
+
+ epUser.setId((long)1);
+ epUser.setManagerId((long) 1234);
+ epUser.setFirstName(TEST);
+ epUser.setLastName(TEST);
+ epUser.setMiddleInitial(TEST);
+ epUser.setPhone(TEST);
+ epUser.setFax(TEST);
+ epUser.setCellular(TEST);
+ epUser.setEmail(TEST);
+ epUser.setAddressId((long) 123);
+ epUser.setAlertMethodCd(TEST);
+ epUser.setHrid(TEST);
+ epUser.setOrgUserId(TEST);
+ epUser.setOrgCode(TEST);
+ epUser.setAddress1(TEST);
+ epUser.setAddress2(TEST);
+ epUser.setCity(TEST);
+ epUser.setState(TEST);
+ epUser.setZipCode(TEST);
+ epUser.setCountry(TEST);
+ epUser.setOrgManagerUserId(TEST);
+ epUser.setLocationClli(TEST);
+ epUser.setBusinessCountryCode(TEST);
+ epUser.setBusinessCountryName(TEST);
+ epUser.setBusinessUnit(TEST);
+ epUser.setBusinessUnitName(TEST);
+ epUser.setDepartment(TEST);
+ epUser.setDepartmentName(TEST);
+ epUser.setCompanyCode(TEST);
+ epUser.setCompany(TEST);
+ epUser.setZipCodeSuffix(TEST);
+ epUser.setJobTitle(TEST);
+ epUser.setCommandChain(TEST);
+ epUser.setSiloStatus(TEST);
+ epUser.setCostCenter(TEST);
+ epUser.setFinancialLocCode(TEST);
+ epUser.setLoginId(TEST);
+ epUser.setLoginPwd(TEST);
+ epUser.setLastLoginDate(new Date());
+ epUser.setActive(false);
+ epUser.setInternal(false);
+ epUser.setSelectedProfileId((long) 12345);
+ epUser.setTimeZoneId((long) 12345);
+ epUser.setOnline(false);
+ epUser.setChatId(TEST);
+ return epUser;
+
+ }
+}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/service/sessionmgt/ManageServiceTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/service/sessionmgt/ManageServiceTest.java
new file mode 100644
index 00000000..940406e9
--- /dev/null
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/service/sessionmgt/ManageServiceTest.java
@@ -0,0 +1,101 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalapp.service.sessionmgt;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.portalapp.portal.service.EPAppService;
+import org.onap.portalsdk.core.domain.sessionmgt.TimeoutVO;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ SystemProperties.class })
+public class ManageServiceTest {
+
+ private static final String TEST="test";
+
+ @InjectMocks
+ ManageService manageService;
+ @Mock
+private EPAppService appService;
+
+ @Mock
+ private SessionCommunication sessionCommunication;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+ @Test
+ public void testFetchSessionSlotCheckInterval() {
+
+ PowerMockito.mockStatic(SystemProperties.class);
+ Mockito.when(SystemProperties.getProperty(SystemProperties.SESSIONTIMEOUT_FEED_CRON)).thenReturn(null);
+ Integer data= manageService.fetchSessionSlotCheckInterval(TEST);
+ assertNotNull(data);
+ }
+
+ @Test
+ public void testExtendSessionTimeOuts()throws Exception {
+ TimeoutVO timeoutVO=new TimeoutVO("testSession", 1800l);
+ ObjectMapper mapper = new ObjectMapper();
+ Map<String, TimeoutVO> sessionTimeoutMap=new HashMap<>();
+ sessionTimeoutMap.put("testPortal", timeoutVO);
+ String sessionTimeoutMapStr= mapper.writeValueAsString(sessionTimeoutMap);
+
+ manageService.extendSessionTimeOuts(TEST,TEST,"1000",sessionTimeoutMapStr);
+
+ }
+
+
+}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/service/sessionmgt/SessionCommunicationTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/service/sessionmgt/SessionCommunicationTest.java
index 4cd2205b..2fdf0fe1 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/service/sessionmgt/SessionCommunicationTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/service/sessionmgt/SessionCommunicationTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -52,6 +52,9 @@ import org.onap.portalapp.portal.transport.OnboardingApp;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
+import org.slf4j.MDC;
+
+import com.att.eelf.configuration.Configuration;
@RunWith(PowerMockRunner.class)
@PrepareForTest({URL.class, HttpURLConnection.class})
@@ -137,5 +140,12 @@ public class SessionCommunicationTest {
PowerMockito.when(huc.getResponseCode()).thenReturn(200);
Boolean actual = sessionCommunication.timeoutSession(app, "test");
assertTrue(actual);
- }
+ }
+
+ @Test
+ public void clear() {
+
+ sessionCommunication.clear(true);
+
+ }
}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/uebhandler/MainUebHandlerTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/uebhandler/MainUebHandlerTest.java
new file mode 100644
index 00000000..a348a294
--- /dev/null
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/uebhandler/MainUebHandlerTest.java
@@ -0,0 +1,75 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalapp.uebhandler;
+
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.portalsdk.core.onboarding.ueb.UebMsg;
+import org.onap.portalsdk.core.onboarding.ueb.UebMsgTypes;
+
+public class MainUebHandlerTest {
+
+ @InjectMocks
+ MainUebHandler mainUebHandler;
+
+ @Mock
+ UebMsg uedMsg;
+ @Mock
+ private WidgetNotificationHandler widgetNotificationHandler;
+
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ //@Test
+ public void runHandler() {
+ Mockito.when(uedMsg.getMsgType()).thenReturn(UebMsgTypes.UEB_MSG_TYPE_WIDGET_NOTIFICATION);
+ ConcurrentLinkedQueue<UebMsg> queue=new ConcurrentLinkedQueue<>();
+ queue.add(uedMsg);
+ mainUebHandler.runHandler(queue);
+
+ }
+}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/uebhandler/WidgetNotificationHandlerTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/uebhandler/WidgetNotificationHandlerTest.java
new file mode 100644
index 00000000..92eda9e0
--- /dev/null
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/uebhandler/WidgetNotificationHandlerTest.java
@@ -0,0 +1,93 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+package org.onap.portalapp.uebhandler;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.portalapp.portal.domain.EPApp;
+import org.onap.portalapp.portal.domain.EPUser;
+import org.onap.portalapp.portal.service.EPAppService;
+import org.onap.portalapp.portal.service.SearchService;
+import org.onap.portalsdk.core.onboarding.ueb.UebMsg;
+
+public class WidgetNotificationHandlerTest {
+
+ @InjectMocks
+ WidgetNotificationHandler widgetNotificationHandler;
+ @Mock
+ EPAppService appSvc;
+
+ @Mock
+ SearchService searchSvc;
+
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void handleWidgetNotification() {
+
+ UebMsg uebMsg=new UebMsg();
+ uebMsg.putMsgId("1");
+ uebMsg.putUserId("13");
+ uebMsg.putMsgType("testType");
+ EPUser user = new EPUser();
+ user.setOrgUserId("123");
+ user.setFirstName("TestFirstName");
+ user.setLastName("TestLastName");
+ EPApp app=new EPApp();
+ app.setUebTopicName("test");
+ List<EPApp> list=new ArrayList<>();
+ list.add(app);
+
+
+ Mockito.when(searchSvc.searchUserByUserId(uebMsg.getUserId())).thenReturn(user);
+ Mockito.when(appSvc.getUserApps(user)).thenReturn(list);
+ widgetNotificationHandler.handleWidgetNotification(uebMsg);
+
+ }
+}