diff options
author | 2019-10-03 12:21:10 +0200 | |
---|---|---|
committer | 2019-10-03 12:22:12 +0200 | |
commit | 1a7472103bde3d850f1f410a7d2ae5b249aef92e (patch) | |
tree | 6a56a85ff3b5f04011dbcfb149e9230fbfe92c3b /portal-BE/src | |
parent | e90cfa3b65b9879d22fc4522f45a22f1014e224e (diff) |
Tests coverage up and some minor bug fixes
Tests coverage up and some minor bug fixes
Issue-ID: PORTAL-710
Change-Id: I796bc731dec6fedae92cac2a659b27f2c0f6d406
Signed-off-by: Dominik Mizyn <d.mizyn@samsung.com>
Diffstat (limited to 'portal-BE/src')
19 files changed, 394 insertions, 54 deletions
diff --git a/portal-BE/src/main/java/org/onap/portal/aop/service/FnUserServiceAOP.java b/portal-BE/src/main/java/org/onap/portal/aop/service/FnUserServiceAOP.java index b96575c6..8c2ff74b 100644 --- a/portal-BE/src/main/java/org/onap/portal/aop/service/FnUserServiceAOP.java +++ b/portal-BE/src/main/java/org/onap/portal/aop/service/FnUserServiceAOP.java @@ -93,7 +93,7 @@ public class FnUserServiceAOP { LOGGER.error("User " + principal.getName() + " try to save not valid fnUser: " + violations); throw new IllegalArgumentException("FnUser is not valid, " + violations); } else { - LOGGER.error("User " + principal.getName() + " send valid fnUser"); + LOGGER.info("User " + principal.getName() + " send valid fnUser"); } } } diff --git a/portal-BE/src/main/java/org/onap/portal/controller/WidgetsCatalogController.java b/portal-BE/src/main/java/org/onap/portal/controller/WidgetsCatalogController.java index d1039f0c..ff8426a3 100644 --- a/portal-BE/src/main/java/org/onap/portal/controller/WidgetsCatalogController.java +++ b/portal-BE/src/main/java/org/onap/portal/controller/WidgetsCatalogController.java @@ -343,8 +343,14 @@ public class WidgetsCatalogController { } @DeleteMapping(value = {"/portalApi/microservices/services/{paramId}"}) - public void deleteUserParameterById(@PathVariable("paramId") long paramId) { - epWidgetCatalogParameterService.deleteUserParameterById(paramId); + public boolean deleteUserParameterById(@PathVariable("paramId") long paramId) { + try { + epWidgetCatalogParameterService.deleteUserParameterById(paramId); + return true; + }catch (Exception e){ + logger.error(EELFLoggerDelegate.errorLogger, e.getMessage()); + return false; + } } @GetMapping(value = {"/portalApi/microservices/download/{widgetId}"}) diff --git a/portal-BE/src/main/java/org/onap/portal/dao/ep/EpMicroserviceParameterDao.java b/portal-BE/src/main/java/org/onap/portal/dao/ep/EpMicroserviceParameterDao.java index 4bcca7ef..add897c9 100644 --- a/portal-BE/src/main/java/org/onap/portal/dao/ep/EpMicroserviceParameterDao.java +++ b/portal-BE/src/main/java/org/onap/portal/dao/ep/EpMicroserviceParameterDao.java @@ -55,7 +55,5 @@ public interface EpMicroserviceParameterDao extends JpaRepository<EpMicroservice @Query void deleteByServiceId(@Param("SERVICEID") Long userId); @Query - void deleteMicroserviceParameterById(@Param("PARAMID") Long userId); - @Query List<EpMicroserviceParameter> getParametersById(@Param("SERVICEID") long serviceId); } diff --git a/portal-BE/src/main/java/org/onap/portal/dao/ep/EpWidgetCatalogParameterDao.java b/portal-BE/src/main/java/org/onap/portal/dao/ep/EpWidgetCatalogParameterDao.java index 04c12324..c5ec1248 100644 --- a/portal-BE/src/main/java/org/onap/portal/dao/ep/EpWidgetCatalogParameterDao.java +++ b/portal-BE/src/main/java/org/onap/portal/dao/ep/EpWidgetCatalogParameterDao.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.Optional; import org.onap.portal.domain.db.ep.EpWidgetCatalogParameter; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; @@ -17,6 +18,7 @@ public interface EpWidgetCatalogParameterDao extends JpaRepository<EpWidgetCatal Optional<List<EpWidgetCatalogParameter>> retrieveByParamId(@Param("PARAMID") Long paramId); @Query + @Modifying void deleteWidgetCatalogParameter(@Param("PARAMID") Long paramId); @Query diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMicroserviceParameter.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMicroserviceParameter.java index 554dd7b5..36c073ac 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMicroserviceParameter.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpMicroserviceParameter.java @@ -59,6 +59,7 @@ import javax.persistence.Table; import javax.validation.constraints.Digits; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -82,11 +83,7 @@ CREATE TABLE `ep_microservice_parameter` ( query = "DELETE FROM EpMicroserviceParameter WHERE service_id =:SERVICEID"), @NamedQuery( name = "EpMicroserviceParameter.getParametersById", - query = "FROM EpMicroserviceParameter WHERE service_id =:SERVICEID"), - @NamedQuery( - name = "EpMicroserviceParameter.deleteMicroserviceParameterById", - query = "DELETE FROM EpMicroserviceParameter WHERE id =:PARAMID" - ) + query = "FROM EpMicroserviceParameter WHERE service_id =:SERVICEID") }) @Table(name = "ep_microservice_parameter", indexes = { @@ -94,13 +91,14 @@ CREATE TABLE `ep_microservice_parameter` ( }) @NoArgsConstructor @AllArgsConstructor +@Builder @Getter @Setter @Entity public class EpMicroserviceParameter implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id", length = 11, nullable = false) @Digits(integer = 11, fraction = 0) private Long id; diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalog.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalog.java index 2068e212..061aafc4 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalog.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalog.java @@ -87,7 +87,7 @@ CREATE TABLE `ep_widget_catalog` ( @Builder public class EpWidgetCatalog implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "widget_id", nullable = false) private Long widgetId; @Column(name = "wdg_name", length = 100, columnDefinition = "varchar(100) default '?'", nullable = false) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalogParameter.java b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalogParameter.java index 8088a8fd..ec6bb563 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalogParameter.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/ep/EpWidgetCatalogParameter.java @@ -84,16 +84,17 @@ CREATE TABLE `ep_widget_catalog_parameter` ( ) */ + @NamedQueries({ @NamedQuery( name = "EpWidgetCatalogParameter.retrieveByParamId", query = "FROM EpWidgetCatalogParameter WHERE paramId.id = :PARAMID"), @NamedQuery( name = "EpWidgetCatalogParameter.deleteWidgetCatalogParameter", - query = "DELETE FROM EpWidgetCatalogParameter WHERE paramId = :PARAMID"), + query = "DELETE FROM EpWidgetCatalogParameter WHERE paramId.id = :PARAMID"), @NamedQuery( name = "EpWidgetCatalogParameter.getUserParamById", - query = "FROM EpWidgetCatalogParameter WHERE paramId = :PARAMID and userId = :USERID and widgetId = :WIDGETID" + query = "FROM EpWidgetCatalogParameter WHERE paramId.id = :PARAMID and userId.userId = :USERID and widgetId.widgetId = :WIDGETID" ) }) @@ -126,7 +127,7 @@ public class EpWidgetCatalogParameter extends DomainVo implements Serializable { @NotNull @Valid private FnUser userId; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST) @JoinColumn(name = "param_id", nullable = false) @NotNull @Valid diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLanguage.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLanguage.java index 0582508d..ad976fc6 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLanguage.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLanguage.java @@ -80,13 +80,11 @@ CREATE TABLE `fn_language` ( @Setter @Entity @JsonInclude() -@SequenceGenerator(name="seq", initialValue=1000, allocationSize=100000) public class FnLanguage implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq") - @Column(name = "language_id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT") - @Digits(integer = 11, fraction = 0) + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "language_id", length = 11, nullable = false) private Long languageId; @Column(name = "language_name", length = 100, nullable = false) @Size(max = 100) diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzSimpleTriggers.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzSimpleTriggers.java index 6f67381f..8bdb1e02 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzSimpleTriggers.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnQzSimpleTriggers.java @@ -76,7 +76,6 @@ CREATE TABLE `fn_qz_simple_triggers` ( @Table(name = "fn_qz_simple_triggers") @NoArgsConstructor @AllArgsConstructor - @Getter @Setter @Entity diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnUser.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnUser.java index ce28d0fd..9b0727d9 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnUser.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnUser.java @@ -183,13 +183,11 @@ CREATE TABLE `fn_user` ( @NoArgsConstructor @AllArgsConstructor @DynamicUpdate -@SequenceGenerator(name = "seq", initialValue = 1000, allocationSize = 100000) public class FnUser extends DomainVo implements UserDetails, Serializable { @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq") - @Column(name = "user_id", length = 11, nullable = false) - @Digits(integer = 11, fraction = 0) + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "user_id", nullable = false) private Long userId; @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @JoinColumn(name = "org_id") diff --git a/portal-BE/src/main/java/org/onap/portal/service/ep/EpMicroserviceParameterService.java b/portal-BE/src/main/java/org/onap/portal/service/ep/EpMicroserviceParameterService.java index e5f84e72..6fa8b7d7 100644 --- a/portal-BE/src/main/java/org/onap/portal/service/ep/EpMicroserviceParameterService.java +++ b/portal-BE/src/main/java/org/onap/portal/service/ep/EpMicroserviceParameterService.java @@ -51,8 +51,10 @@ import org.onap.portal.domain.dto.ecomp.MicroserviceParameter; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service +@Transactional public class EpMicroserviceParameterService { EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EpWidgetCatalogParameterService.class); @@ -88,4 +90,15 @@ public class EpMicroserviceParameterService { public EpMicroserviceParameter save(EpMicroserviceParameter epMicroserviceParameter){ return epMicroserviceParameterDao.save(epMicroserviceParameter); } + + @Transactional + public boolean deleteMicroserviceParameterById(final Long paramid){ + try { + epMicroserviceParameterDao.deleteById(paramid); + return true; + }catch (Exception e){ + logger.error(EELFLoggerDelegate.errorLogger, e.getMessage()); + return false; + } + } } diff --git a/portal-BE/src/main/java/org/onap/portal/service/ep/EpWidgetCatalogParameterService.java b/portal-BE/src/main/java/org/onap/portal/service/ep/EpWidgetCatalogParameterService.java index f2497f85..75cc9aa7 100644 --- a/portal-BE/src/main/java/org/onap/portal/service/ep/EpWidgetCatalogParameterService.java +++ b/portal-BE/src/main/java/org/onap/portal/service/ep/EpWidgetCatalogParameterService.java @@ -42,40 +42,51 @@ package org.onap.portal.service.ep; import java.util.ArrayList; import java.util.List; -import javax.transaction.Transactional; -import org.onap.portal.dao.ep.EpMicroserviceParameterDao; import org.onap.portal.dao.ep.EpWidgetCatalogParameterDao; import org.onap.portal.domain.db.ep.EpWidgetCatalogParameter; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service +@Transactional public class EpWidgetCatalogParameterService { EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EpWidgetCatalogParameterService.class); private final EpWidgetCatalogParameterDao epWidgetCatalogParameterDao; - private final EpMicroserviceParameterDao epMicroserviceParameterDao; + private final EpMicroserviceParameterService epMicroserviceParameterService; @Autowired public EpWidgetCatalogParameterService( final EpWidgetCatalogParameterDao epWidgetCatalogParameterDao, - final EpMicroserviceParameterDao epMicroserviceParameterDao) { + final EpMicroserviceParameterService epMicroserviceParameterService) { this.epWidgetCatalogParameterDao = epWidgetCatalogParameterDao; - this.epMicroserviceParameterDao = epMicroserviceParameterDao; + this.epMicroserviceParameterService = epMicroserviceParameterService; } - public List<EpWidgetCatalogParameter> getUserParameterById(Long paramId) { + public List<EpWidgetCatalogParameter> getUserParameterById(final Long paramId) { return epWidgetCatalogParameterDao.retrieveByParamId(paramId).orElse(new ArrayList<>()); } - public void deleteUserParameterById(Long paramId) { - epWidgetCatalogParameterDao.deleteWidgetCatalogParameter(paramId); - epMicroserviceParameterDao.deleteMicroserviceParameterById(paramId); + public boolean deleteUserParameterById(final Long paramId) { + return (deleteByParamId(paramId) && + epMicroserviceParameterService.deleteMicroserviceParameterById(paramId)); } - public EpWidgetCatalogParameter getUserParamById(Long widgetId, Long userId, Long paramId) { + @Transactional + public boolean deleteByParamId(final Long paramId) { + try { + epWidgetCatalogParameterDao.deleteWidgetCatalogParameter(paramId); + return true; + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, e.getMessage()); + return false; + } + } + + public EpWidgetCatalogParameter getUserParamById(final Long widgetId, final Long userId, final Long paramId) { EpWidgetCatalogParameter widgetParam = null; List<EpWidgetCatalogParameter> list = epWidgetCatalogParameterDao .getUserParamById(widgetId, userId, paramId) @@ -89,7 +100,7 @@ public class EpWidgetCatalogParameterService { } @Transactional - public void saveUserParameter(EpWidgetCatalogParameter newParameter) { + public void saveUserParameter(final EpWidgetCatalogParameter newParameter) { epWidgetCatalogParameterDao.save(newParameter); } } diff --git a/portal-BE/src/main/resources/application.properties b/portal-BE/src/main/resources/application.properties index 30c0beeb..948ef969 100644 --- a/portal-BE/src/main/resources/application.properties +++ b/portal-BE/src/main/resources/application.properties @@ -7,8 +7,6 @@ spring.session.jdbc.initialize-schema=always spring.datasource.continueOnError=true spring.datasource.username=portal spring.datasource.password=Test123456 -log4j.logger.org.hibernate=info - #H2 config spring.h2.console.settings.web-allow-others=true spring.h2.console.enabled=true @@ -18,4 +16,17 @@ spring.jpa.hibernate.ddl-auto=update spring.jpa.database=mysql spring.jpa.show-sql=true -spring.jooq.sql-dialect=MARIADB
\ No newline at end of file +spring.jooq.sql-dialect=MARIADB + +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%c] - %m%n + +log4j.rootLogger=info, stdout +# basic log level for all messages +log4j.logger.org.hibernate=info + +# SQL statements and parameters +log4j.logger.org.hibernate.SQL=debug +log4j.logger.org.hibernate.type.descriptor.sql=trace
\ No newline at end of file diff --git a/portal-BE/src/main/resources/data.sql b/portal-BE/src/main/resources/data.sql index c4223441..bafd286f 100644 --- a/portal-BE/src/main/resources/data.sql +++ b/portal-BE/src/main/resources/data.sql @@ -129,7 +129,7 @@ UNLOCK TABLES; LOCK TABLES `ep_widget_catalog` WRITE; /*!40000 ALTER TABLE `ep_widget_catalog` DISABLE KEYS */; -INSERT INTO `ep_widget_catalog` (`widget_id`, `wdg_name`, `service_id`, `wdg_desc`, `wdg_file_loc`, `all_user_flag`) VALUES (1,'News',1,'News','news-widget.zip',1),(2,'Events',2,'Events','events-widget.zip',1),(3,'Resources',3,'Resources','resources-widget.zip',1),(4,'Portal-Common-Scheduler',4,'Portal-Common-Scheduler','portal-common-scheduler-widget.zip',1); +INSERT INTO `ep_widget_catalog` (`wdg_name`, `service_id`, `wdg_desc`, `wdg_file_loc`, `all_user_flag`) VALUES ('News',1,'News','news-widget.zip',1),('Events',2,'Events','events-widget.zip',1),('Resources',3,'Resources','resources-widget.zip',1),('Portal-Common-Scheduler',4,'Portal-Common-Scheduler','portal-common-scheduler-widget.zip',1); /*!40000 ALTER TABLE `ep_widget_catalog` ENABLE KEYS */; UNLOCK TABLES; @@ -190,7 +190,7 @@ UNLOCK TABLES; LOCK TABLES `fn_language` WRITE; /*!40000 ALTER TABLE `fn_language` DISABLE KEYS */; -INSERT INTO `fn_language` (`language_id`, `language_name`, `language_alias`) VALUES (1,'English','EN'),(2,'简体ä¸æ–‡','CN'); +INSERT INTO `fn_language` (`language_name`, `language_alias`) VALUES ('English','EN'),('简体ä¸æ–‡','CN'); /*!40000 ALTER TABLE `fn_language` ENABLE KEYS */; UNLOCK TABLES; @@ -462,7 +462,7 @@ UNLOCK TABLES; LOCK TABLES `fn_user` WRITE; /*!40000 ALTER TABLE `fn_user` DISABLE KEYS */; -INSERT INTO `fn_user` (`user_id`, `org_id`, `manager_id`, `first_name`, `middle_name`, `last_name`, `phone`, `fax`, `cellular`, `email`, `address_id`, `alert_method_cd`, `hrid`, `org_user_id`, `org_code`, `login_id`, `login_pwd`, `last_login_date`, `active_yn`, `created_id`, `created_date`, `modified_id`, `modified_date`, `is_internal_yn`, `address_line_1`, `address_line_2`, `city`, `state_cd`, `zip_code`, `country_cd`, `location_clli`, `org_manager_userid`, `company`, `department_name`, `job_title`, `timezone`, `department`, `business_unit`, `business_unit_name`, `cost_center`, `fin_loc_code`, `silo_status`, `language_id`) VALUES (1,NULL,NULL,'Demo',NULL,'User',NULL,NULL,NULL,'demo@openecomp.org',NULL,NULL,NULL,'demo',NULL,'demo','demo123','2019-08-08 12:18:17',1,NULL,'2016-10-14 21:00:00',1,'2019-08-08 12:18:17',0,NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(2,NULL,NULL,'Jimmy',NULL,'Hendrix',NULL,NULL,NULL,'admin@onap.org',NULL,NULL,NULL,'jh0003',NULL,'jh0003','demo123','2019-08-08 10:16:11',1,NULL,'2016-10-14 21:00:00',1,'2019-08-08 10:16:11',0,NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(3,NULL,NULL,'Carlos',NULL,'Santana',NULL,NULL,NULL,'designer@onap.org',NULL,NULL,NULL,'cs0008',NULL,'cs0008','demo123','2016-10-20 15:11:16',1,NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16',0,NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(4,NULL,NULL,'Joni',NULL,'Mitchell',NULL,NULL,NULL,'tester@onap.org',NULL,NULL,NULL,'jm0007',NULL,'jm0007','demo123','2016-10-20 15:11:16',1,NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16',0,NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(5,NULL,NULL,'Steve',NULL,'Regev',NULL,NULL,NULL,'ops@onap.org',NULL,NULL,NULL,'op0001',NULL,'op0001','demo123','2016-10-20 15:11:16',1,NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16',0,NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(6,NULL,NULL,'David',NULL,'Shadmi',NULL,NULL,NULL,'governor@onap.org',NULL,NULL,NULL,'gv0001',NULL,'gv0001','demo123','2016-10-20 15:11:16',1,NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16',0,NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(7,NULL,NULL,'Teddy',NULL,'Isashar',NULL,NULL,NULL,'pm1@onap.org',NULL,NULL,NULL,'pm0001',NULL,'pm0001','demo123','2016-10-20 15:11:16',1,NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16',0,NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(8,NULL,NULL,'Eden',NULL,'Rozin',NULL,NULL,NULL,'ps1@onap.org',NULL,NULL,NULL,'ps0001',NULL,'ps0001','demo123','2016-10-20 15:11:16',1,NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16',0,NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(9,NULL,NULL,'vid1',NULL,'user',NULL,NULL,NULL,'vid1@onap.org',NULL,NULL,NULL,'vid1',NULL,'vid1','demo123','2016-10-20 15:11:16',1,NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16',0,NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(10,NULL,NULL,'vid2',NULL,'user',NULL,NULL,NULL,'vid2@onap.org',NULL,NULL,NULL,'vid2',NULL,'vid2','demo123','2016-10-20 15:11:16',1,NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16',0,NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(11,NULL,NULL,'vid3',NULL,'user',NULL,NULL,NULL,'vid3@onap.org',NULL,NULL,NULL,'vid3',NULL,'vid3','demo123','2016-10-20 15:11:16',1,NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16',0,NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(12,NULL,NULL,'steve',NULL,'user',NULL,NULL,NULL,'steve@onap.org',NULL,NULL,NULL,'steve',NULL,'steve','demo123','2017-05-19 15:11:16',1,NULL,'2017-05-19 21:00:00',1,'2017-05-19 15:11:16',0,NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1); +INSERT INTO `fn_user` ( `org_id`, `manager_id`, `first_name`, `middle_name`, `last_name`, `phone`, `fax`, `cellular`, `email`, `address_id`, `alert_method_cd`, `hrid`, `org_user_id`, `org_code`, `login_id`, `login_pwd`, `last_login_date`, `active_yn`, `created_id`, `created_date`, `modified_id`, `modified_date`, `is_internal_yn`, `address_line_1`, `address_line_2`, `city`, `state_cd`, `zip_code`, `country_cd`, `location_clli`, `org_manager_userid`, `company`, `department_name`, `job_title`, `timezone`, `department`, `business_unit`, `business_unit_name`, `cost_center`, `fin_loc_code`, `silo_status`, `language_id`) VALUES (NULL,NULL,'Demo',NULL,'User',NULL,NULL,NULL,'demo@openecomp.org',NULL,NULL,NULL,'demo',NULL,'demo','demo123','2019-08-08 12:18:17',1,NULL,'2016-10-14 21:00:00',1,'2019-08-08 12:18:17',0,NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(NULL,NULL,'Jimmy',NULL,'Hendrix',NULL,NULL,NULL,'admin@onap.org',NULL,NULL,NULL,'jh0003',NULL,'jh0003','demo123','2019-08-08 10:16:11',1,NULL,'2016-10-14 21:00:00',1,'2019-08-08 10:16:11',0,NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(NULL,NULL,'Carlos',NULL,'Santana',NULL,NULL,NULL,'designer@onap.org',NULL,NULL,NULL,'cs0008',NULL,'cs0008','demo123','2016-10-20 15:11:16',1,NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16',0,NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(NULL,NULL,'Joni',NULL,'Mitchell',NULL,NULL,NULL,'tester@onap.org',NULL,NULL,NULL,'jm0007',NULL,'jm0007','demo123','2016-10-20 15:11:16',1,NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16',0,NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(NULL,NULL,'Steve',NULL,'Regev',NULL,NULL,NULL,'ops@onap.org',NULL,NULL,NULL,'op0001',NULL,'op0001','demo123','2016-10-20 15:11:16',1,NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16',0,NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(NULL,NULL,'David',NULL,'Shadmi',NULL,NULL,NULL,'governor@onap.org',NULL,NULL,NULL,'gv0001',NULL,'gv0001','demo123','2016-10-20 15:11:16',1,NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16',0,NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(NULL,NULL,'Teddy',NULL,'Isashar',NULL,NULL,NULL,'pm1@onap.org',NULL,NULL,NULL,'pm0001',NULL,'pm0001','demo123','2016-10-20 15:11:16',1,NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16',0,NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(NULL,NULL,'Eden',NULL,'Rozin',NULL,NULL,NULL,'ps1@onap.org',NULL,NULL,NULL,'ps0001',NULL,'ps0001','demo123','2016-10-20 15:11:16',1,NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16',0,NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(NULL,NULL,'vid1',NULL,'user',NULL,NULL,NULL,'vid1@onap.org',NULL,NULL,NULL,'vid1',NULL,'vid1','demo123','2016-10-20 15:11:16',1,NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16',0,NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(NULL,NULL,'vid2',NULL,'user',NULL,NULL,NULL,'vid2@onap.org',NULL,NULL,NULL,'vid2',NULL,'vid2','demo123','2016-10-20 15:11:16',1,NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16',0,NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(NULL,NULL,'vid3',NULL,'user',NULL,NULL,NULL,'vid3@onap.org',NULL,NULL,NULL,'vid3',NULL,'vid3','demo123','2016-10-20 15:11:16',1,NULL,'2016-10-14 21:00:00',1,'2016-10-20 15:11:16',0,NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1),(NULL,NULL,'steve',NULL,'user',NULL,NULL,NULL,'steve@onap.org',NULL,NULL,NULL,'steve',NULL,'steve','demo123','2017-05-19 15:11:16',1,NULL,'2017-05-19 21:00:00',1,'2017-05-19 15:11:16',0,NULL,NULL,NULL,'NJ',NULL,'US',NULL,NULL,NULL,NULL,NULL,10,NULL,NULL,NULL,NULL,NULL,NULL,1); /*!40000 ALTER TABLE `fn_user` ENABLE KEYS */; UNLOCK TABLES; diff --git a/portal-BE/src/test/java/org/onap/portal/controller/WidgetMSControllerTest.java b/portal-BE/src/test/java/org/onap/portal/controller/WidgetMSControllerTest.java index 2f9f4235..3dd1fc2f 100644 --- a/portal-BE/src/test/java/org/onap/portal/controller/WidgetMSControllerTest.java +++ b/portal-BE/src/test/java/org/onap/portal/controller/WidgetMSControllerTest.java @@ -1,3 +1,43 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modifications Copyright (c) 2019 Samsung + * =================================================================== + * + * 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.portal.controller; import static org.junit.jupiter.api.Assertions.*; diff --git a/portal-BE/src/test/java/org/onap/portal/controller/WidgetsCatalogControllerTest.java b/portal-BE/src/test/java/org/onap/portal/controller/WidgetsCatalogControllerTest.java index 8c2adc9d..c04f50e4 100644 --- a/portal-BE/src/test/java/org/onap/portal/controller/WidgetsCatalogControllerTest.java +++ b/portal-BE/src/test/java/org/onap/portal/controller/WidgetsCatalogControllerTest.java @@ -1,17 +1,57 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modifications Copyright (c) 2019 Samsung + * =================================================================== + * + * 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.portal.controller; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.time.LocalDateTime; import java.util.Collections; import java.util.HashSet; import java.util.List; import javax.transaction.Transactional; -import org.hibernate.Hibernate; import org.junit.Test; import org.junit.runner.RunWith; -import org.onap.portal.dao.fn.EpWidgetCatalogDao; import org.onap.portal.domain.db.ep.EpMicroserviceParameter; import org.onap.portal.domain.db.ep.EpWidgetCatalog; import org.onap.portal.domain.db.ep.EpWidgetCatalogParameter; @@ -22,7 +62,6 @@ import org.onap.portal.service.ep.EpMicroserviceParameterService; import org.onap.portal.service.ep.EpWidgetCatalogParameterService; import org.onap.portal.service.ep.EpWidgetCatalogService; import org.onap.portal.service.fn.FnLanguageService; -import org.onap.portal.service.fn.FnUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; @@ -40,8 +79,6 @@ public class WidgetsCatalogControllerTest { @Autowired FnLanguageService fnLanguageService; @Autowired - FnUserService fnUserService; - @Autowired EpWidgetCatalogParameterService epWidgetCatalogParameterService; @Autowired EpMicroserviceParameterService epMicroserviceParameterService; @@ -95,7 +132,6 @@ public class WidgetsCatalogControllerTest { public void getUserParameterById() { //Given EpWidgetCatalog widget = EpWidgetCatalog.builder() - .widgetId(54L) .wdgName("Name") .wdgFileLoc("loc") .allUserFlag(true) @@ -119,7 +155,32 @@ public class WidgetsCatalogControllerTest { } @Test + @Transactional public void deleteUserParameterById() { + //Given + EpWidgetCatalog widget = EpWidgetCatalog.builder() + .wdgName("Name") + .wdgFileLoc("loc") + .allUserFlag(true) + .build(); + epWidgetCatalogService.save(widget); + EpMicroserviceParameter parameter = new EpMicroserviceParameter(); + epMicroserviceParameterService.save(parameter); + FnLanguage language = FnLanguage.builder().languageAlias("TS").languageName("TEST").build(); + fnLanguageService.save(principal, language); + FnUser user = buildFnUser(); + language.setFnUsers(new HashSet<>(Collections.singleton(user))); + user.setLanguageId(language); + EpWidgetCatalogParameter data = EpWidgetCatalogParameter.builder() + .widgetId(widget).userId(user).paramId(parameter).userValue("TestData").build(); + //When + assertEquals(0, widgetsCatalogController.getUserParameterById(parameter.getId()).size()); + epWidgetCatalogParameterService.saveUserParameter(data); + //Then assert + assertEquals(1, widgetsCatalogController.getUserParameterById(parameter.getId()).size()); + assertTrue(widgetsCatalogController.deleteUserParameterById(parameter.getId())); + assertEquals(0, widgetsCatalogController.getUserParameterById(parameter.getId()).size()); + } @Test diff --git a/portal-BE/src/test/java/org/onap/portal/service/ep/EpMicroserviceParameterServiceTest.java b/portal-BE/src/test/java/org/onap/portal/service/ep/EpMicroserviceParameterServiceTest.java new file mode 100644 index 00000000..b4427ef3 --- /dev/null +++ b/portal-BE/src/test/java/org/onap/portal/service/ep/EpMicroserviceParameterServiceTest.java @@ -0,0 +1,68 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modifications Copyright (c) 2019 Samsung + * =================================================================== + * + * 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.portal.service.ep; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; +import org.junit.runner.RunWith; +import org.onap.portal.domain.db.ep.EpMicroserviceParameter; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +@TestPropertySource(locations = "classpath:test.properties") +class EpMicroserviceParameterServiceTest { + + @Autowired + EpMicroserviceParameterService epMicroserviceParameterService; + + @Test + void deleteMicroserviceParameterById() { + EpMicroserviceParameter parameter = EpMicroserviceParameter.builder() + .build(); + epMicroserviceParameterService.save(parameter); + assertTrue(epMicroserviceParameterService.deleteMicroserviceParameterById(parameter.getId())); + } +}
\ No newline at end of file diff --git a/portal-BE/src/test/java/org/onap/portal/service/ep/EpWidgetCatalogParameterServiceTest.java b/portal-BE/src/test/java/org/onap/portal/service/ep/EpWidgetCatalogParameterServiceTest.java new file mode 100644 index 00000000..f123f95a --- /dev/null +++ b/portal-BE/src/test/java/org/onap/portal/service/ep/EpWidgetCatalogParameterServiceTest.java @@ -0,0 +1,128 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modifications Copyright (c) 2019 Samsung + * =================================================================== + * + * 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.portal.service.ep; + +import static org.junit.jupiter.api.Assertions.*; + +import java.time.LocalDateTime; +import java.util.Collections; +import java.util.HashSet; +import org.junit.jupiter.api.Test; +import org.junit.runner.RunWith; +import org.onap.portal.controller.WidgetsCatalogController; +import org.onap.portal.domain.db.ep.EpMicroserviceParameter; +import org.onap.portal.domain.db.ep.EpWidgetCatalog; +import org.onap.portal.domain.db.ep.EpWidgetCatalogParameter; +import org.onap.portal.domain.db.fn.FnLanguage; +import org.onap.portal.domain.db.fn.FnUser; +import org.onap.portal.service.fn.FnLanguageService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.transaction.annotation.Transactional; + +@RunWith(SpringRunner.class) +@SpringBootTest +@TestPropertySource(locations = "classpath:test.properties") +class EpWidgetCatalogParameterServiceTest { + private UsernamePasswordAuthenticationToken principal = new UsernamePasswordAuthenticationToken("demo", + "demo123"); + @Autowired + private EpWidgetCatalogParameterService epWidgetCatalogParameterService; + @Autowired + private WidgetsCatalogController widgetsCatalogController; + @Autowired + private + FnLanguageService fnLanguageService; + @Autowired + private EpMicroserviceParameterService epMicroserviceParameterService; + @Autowired + private + EpWidgetCatalogService epWidgetCatalogService; + + @Test + void deleteUserParameterById() { + } + + @Test + @Transactional + void deleteByParamId() { + //Given + EpWidgetCatalog widget = EpWidgetCatalog.builder() + .wdgName("Name") + .wdgFileLoc("loc") + .allUserFlag(true) + .build(); + epWidgetCatalogService.save(widget); + EpMicroserviceParameter parameter = new EpMicroserviceParameter(); + epMicroserviceParameterService.save(parameter); + FnLanguage language = FnLanguage.builder().languageAlias("TS").languageName("TEST").build(); + fnLanguageService.save(principal, language); + FnUser user = buildFnUser(); + language.setFnUsers(new HashSet<>(Collections.singleton(user))); + user.setLanguageId(language); + EpWidgetCatalogParameter data = EpWidgetCatalogParameter.builder() + .widgetId(widget).userId(user).paramId(parameter).userValue("TestData").build(); + //When + assertEquals(0, widgetsCatalogController.getUserParameterById(parameter.getId()).size()); + epWidgetCatalogParameterService.saveUserParameter(data); + //Then + assertEquals(1, epWidgetCatalogParameterService.getUserParameterById(parameter.getId()).size()); + epWidgetCatalogParameterService.deleteByParamId(parameter.getId()); + assertEquals(0, epWidgetCatalogParameterService.getUserParameterById(parameter.getId()).size()); + //Clean + + + } + + private FnUser buildFnUser(){ + return FnUser.builder() + .lastLoginDate(LocalDateTime.now()) + .activeYn(true) + .modifiedDate(LocalDateTime.now()) + .createdDate(LocalDateTime.now()) + .isInternalYn(true) + .guest(false) + .build(); + } +}
\ No newline at end of file diff --git a/portal-BE/src/test/java/org/onap/portal/service/fn/FnUserServiceTest.java b/portal-BE/src/test/java/org/onap/portal/service/fn/FnUserServiceTest.java index 4f960b46..e4083881 100644 --- a/portal-BE/src/test/java/org/onap/portal/service/fn/FnUserServiceTest.java +++ b/portal-BE/src/test/java/org/onap/portal/service/fn/FnUserServiceTest.java @@ -73,29 +73,37 @@ class FnUserServiceTest { @Test void saveUser(){ - FnUser actual = fnUserService.getUser(1L).get(); + //Given + //FnLuTimezone fnLuTimezone = fnLuTimezoneService.getById(10L).get(); + FnLanguage language = fnLanguageService.findById(1L).get(); FnUser expected = FnUser.builder().build(); - expected.setUserId(123L); expected.setFirstName("Demo"); expected.setLastName("User"); expected.setEmail("demo@openecomp.org"); expected.setOrgUserId("demo"); - expected.setTimezone(fnLuTimezoneService.getById(10L).orElse(new FnLuTimezone())); - expected.setLoginId("demo"); + //expected.setTimezone(fnLuTimezone); + expected.setLoginId("demoTest"); expected.setLoginPwd("demo123"); expected.setLastLoginDate(LocalDateTime.parse("2019-08-08T12:18:17")); expected.setActiveYn(true); expected.setCreatedDate(LocalDateTime.parse("2016-10-14T21:00")); - expected.setModifiedId(actual); expected.setModifiedDate(LocalDateTime.parse("2019-08-08T12:18:17")); expected.setIsInternalYn(false); expected.setStateCd("NJ"); expected.setCountryCd("US"); - expected.setLanguageId(fnLanguageService.findById(1L).orElse(new FnLanguage())); + expected.setLanguageId(language); expected.setGuest(false); + + //fnLuTimezone.getFnUsers().add(expected); + language.getFnUsers().add(expected); + + //When fnUserService.saveFnUser(principal, expected); - System.out.println(expected.getActiveYn()); + FnUser actual = fnUserService.getUser(expected.getUserId()).get(); + //Then + assertEquals(expected.getUserId(), actual.getUserId()); + assertEquals(expected.getLoginPwd(), actual.getLoginPwd()); //Clean up fnUserService.deleteUser(expected); } |