summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPATTANAYAK, SAUMYA SWARUP (sp931a) <sp931a@att.com>2020-04-27 12:40:47 -0400
committerPATTANAYAK, SAUMYA SWARUP (sp931a) <sp931a@att.com>2020-04-27 18:07:13 -0400
commitcb4ff59b1ac8b137bd1453ddec400679ba83b225 (patch)
tree3ec3b180b8ee9e0c349ffbd13c3ba89ac627d806
parent328da2e4cf0c4155a4d29718cb5f57628d7a5277 (diff)
SB 2.x Migration for portal widget mS
Migrating from Springboot 1.x to 2.x along with other associated libraries. Issue-ID: PORTAL-892 Signed-off-by: sp931a <sp931a@att.com> Change-Id: Ibb88c867059218cc0e7694c4a654d1856638d412
-rw-r--r--ecomp-portal-widget-ms/widget-ms/pom.xml16
-rw-r--r--ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/controller/WidgetsCatalogController.java6
-rw-r--r--ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/App.java2
-rw-r--r--ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/MicroserviceData.java2
-rw-r--r--ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/MicroserviceParameter.java2
-rw-r--r--ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/RoleApp.java2
-rw-r--r--ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/WidgetCatalog.java2
-rw-r--r--ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/hibernate/HibernateConfiguration.java2
-rw-r--r--ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/MicroserviceServiceImpl.java6
-rw-r--r--ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/WidgetCatalogServiceImpl.java6
-rw-r--r--ecomp-portal-widget-ms/widget-ms/src/main/resources/application.properties12
-rw-r--r--ecomp-portal-widget-ms/widget-ms/src/test/java/org/onap/portalapp/widget/service/impl/WidgetCatalogServiceImplTest.java3
-rw-r--r--ecomp-portal-widget-ms/widget-ms/src/test/java/org/onap/portalapp/widget/test/controller/WidgetsCatalogControllerTest.java16
13 files changed, 39 insertions, 38 deletions
diff --git a/ecomp-portal-widget-ms/widget-ms/pom.xml b/ecomp-portal-widget-ms/widget-ms/pom.xml
index 4095388c..f4275067 100644
--- a/ecomp-portal-widget-ms/widget-ms/pom.xml
+++ b/ecomp-portal-widget-ms/widget-ms/pom.xml
@@ -7,7 +7,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
- <version>1.5.11.RELEASE</version>
+ <version>2.2.5.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
@@ -22,10 +22,10 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
- <hibernate.version>4.3.11.Final</hibernate.version>
+ <hibernate.version>5.4.14.Final</hibernate.version>
<skipTests>false</skipTests>
<!-- Replicate this from OParent -->
- <jacocoVersion>0.7.6.201602180812</jacocoVersion>
+ <jacocoVersion>0.8.2</jacocoVersion>
</properties>
<dependencies>
@@ -68,7 +68,7 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
- <!-- <version>${hibernate.version}</version> -->
+ <version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
@@ -96,7 +96,7 @@
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
- <version>1.9</version>
+ <version>2.1.0</version>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
@@ -109,7 +109,7 @@
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
- <!-- <version>1.6.1</version> -->
+ <version>1.6.1</version>
<exclusions>
<exclusion>
<groupId>jaxme</groupId>
@@ -151,7 +151,7 @@
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
- <version>8.5.28</version>
+ <version>9.0.33</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
@@ -181,7 +181,7 @@
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
- <version>4.2.13.RELEASE</version>
+ <version>5.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/controller/WidgetsCatalogController.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/controller/WidgetsCatalogController.java
index b1450b6d..5f458c1d 100644
--- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/controller/WidgetsCatalogController.java
+++ b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/controller/WidgetsCatalogController.java
@@ -37,12 +37,12 @@ public class WidgetsCatalogController {
@Value("${server.port}")
String port;
- @Value("${server.contextPath}")
+ @Value("${server.servlet.context-path}")
String context;
- @Value("${security.user.name}")
+ @Value("${spring.security.user.name}")
String security_user;
- @Value("${security.user.password}")
+ @Value("${spring.security.user.password}")
String security_pass;
@Autowired
diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/App.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/App.java
index 212826cd..46ee814c 100644
--- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/App.java
+++ b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/App.java
@@ -21,7 +21,7 @@ public class App implements Serializable{
@Id
@Column(name = "APP_ID")
- @GeneratedValue(strategy=GenerationType.AUTO)
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
@Digits(integer = 11, fraction = 0)
private Long appId;
diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/MicroserviceData.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/MicroserviceData.java
index 43e7b2b0..2ed49ab4 100644
--- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/MicroserviceData.java
+++ b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/MicroserviceData.java
@@ -26,7 +26,7 @@ public class MicroserviceData {
@Id
@Column(name = "id")
@Digits(integer = 11, fraction = 0)
- @GeneratedValue(strategy=GenerationType.AUTO)
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
@Column(name = "name")
diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/MicroserviceParameter.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/MicroserviceParameter.java
index 7207d0ae..cd9236da 100644
--- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/MicroserviceParameter.java
+++ b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/MicroserviceParameter.java
@@ -24,7 +24,7 @@ public class MicroserviceParameter {
@Id
@Column(name = "id")
- @GeneratedValue(strategy=GenerationType.AUTO)
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
@Digits(integer = 11, fraction = 0)
private Long id;
diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/RoleApp.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/RoleApp.java
index aae9bfed..173a1430 100644
--- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/RoleApp.java
+++ b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/RoleApp.java
@@ -33,7 +33,7 @@ public class RoleApp implements Serializable{
@Id
@Column(name = "ROLE_ID")
- @GeneratedValue(strategy=GenerationType.AUTO)
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
@Digits(integer = 11, fraction = 0)
private Long roleId;
diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/WidgetCatalog.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/WidgetCatalog.java
index 1dc0582c..a822c5a2 100644
--- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/WidgetCatalog.java
+++ b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/domain/WidgetCatalog.java
@@ -30,7 +30,7 @@ public class WidgetCatalog{
@Id
@Column(name = "widget_id")
- @GeneratedValue(strategy=GenerationType.AUTO)
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
@Digits(integer = 11, fraction = 0)
private long id;
diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/hibernate/HibernateConfiguration.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/hibernate/HibernateConfiguration.java
index b52631f1..ac25077b 100644
--- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/hibernate/HibernateConfiguration.java
+++ b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/hibernate/HibernateConfiguration.java
@@ -6,7 +6,7 @@ import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
-import org.springframework.orm.hibernate4.LocalSessionFactoryBean;
+import org.springframework.orm.hibernate5.LocalSessionFactoryBean;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/MicroserviceServiceImpl.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/MicroserviceServiceImpl.java
index fed70ad9..a02667de 100644
--- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/MicroserviceServiceImpl.java
+++ b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/MicroserviceServiceImpl.java
@@ -41,7 +41,7 @@ public class MicroserviceServiceImpl implements MicroserviceService{
Transaction tx = session.beginTransaction();
session.save(newService);
tx.commit();
- session.flush();
+// session.flush();
session.close();
}
catch(Exception e){
@@ -58,7 +58,7 @@ public class MicroserviceServiceImpl implements MicroserviceService{
Transaction tx = session.beginTransaction();
session.save(newParameter);
tx.commit();
- session.flush();
+// session.flush();
session.close();
}
catch(Exception e){
@@ -77,7 +77,7 @@ public class MicroserviceServiceImpl implements MicroserviceService{
List<MicroserviceData> services = criteria.list();
logger.debug("MicroserviceServiceImpl.getMicroserviceByName: result={}", services);
- session.flush();
+// session.flush();
session.close();
return (services.size() > 0) ? services.get(0).getId() : null;
diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/WidgetCatalogServiceImpl.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/WidgetCatalogServiceImpl.java
index 59180d37..f5558e2e 100644
--- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/WidgetCatalogServiceImpl.java
+++ b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/WidgetCatalogServiceImpl.java
@@ -191,7 +191,7 @@ public class WidgetCatalogServiceImpl implements WidgetCatalogService {
Transaction tx = session.beginTransaction();
session.save(newWidgetCatalog);
tx.commit();
- session.flush();
+ //session.flush();
session.close();
updateAppId(newWidgetCatalog.getId(), newWidgetCatalog.getWidgetRoles());
}
@@ -217,7 +217,7 @@ public class WidgetCatalogServiceImpl implements WidgetCatalogService {
Transaction tx = session.beginTransaction();
session.update(newWidgetCatalog);
tx.commit();
- session.flush();
+ //session.flush();
session.close();
updateAppId(newWidgetCatalog.getId(), newWidgetCatalog.getWidgetRoles());
}catch(Exception e){
@@ -268,7 +268,7 @@ public class WidgetCatalogServiceImpl implements WidgetCatalogService {
List<MicroserviceData> widgets = criteria.list();
logger.debug("WidgetCatalogServiceImpl.getWidgetIdByName: result={}", widgets);
- session.flush();
+// session.flush();
session.close();
return (widgets.size() > 0) ? true : false;
diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/resources/application.properties b/ecomp-portal-widget-ms/widget-ms/src/main/resources/application.properties
index 42483b7f..82b26d6e 100644
--- a/ecomp-portal-widget-ms/widget-ms/src/main/resources/application.properties
+++ b/ecomp-portal-widget-ms/widget-ms/src/main/resources/application.properties
@@ -1,22 +1,22 @@
## General App Properties
-server.contextPath=/widget
+server.servlet.context-path=/widget
server.port=9082
-spring.http.multipart.max-file-size=128MB
-spring.http.multipart.max-request-size=128MB
+spring.servlet.multipart.max-file-size=128MB
+spring.servlet.multipart.max-request-size=128MB
microservice.widget.location=/tmp
## App DB Properties
spring.datasource.url=jdbc:mariadb://localhost:3306/portal
spring.datasource.username=root
-spring.datasource.password=root
+spring.datasource.password=welcome2ibm
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
spring.database.driver.classname=org.mariadb.jdbc.Driver
spring.jpa.show-sql=false
spring.jpa.properties.hibernate.format_sql=false
## Basic Authentication Properties
-security.user.name=widget_user
-security.user.password=ENC(IjywcRnI9+nuVEh9+OFFiRWAjBT1n718)
+spring.security.user.name=widget_user
+spring.security.user.password=ENC(IjywcRnI9+nuVEh9+OFFiRWAjBT1n718)
account.user.name=portal
account.user.password=6APqvG4AU2rfLgCvMdySwQ==
diff --git a/ecomp-portal-widget-ms/widget-ms/src/test/java/org/onap/portalapp/widget/service/impl/WidgetCatalogServiceImplTest.java b/ecomp-portal-widget-ms/widget-ms/src/test/java/org/onap/portalapp/widget/service/impl/WidgetCatalogServiceImplTest.java
index 933710d2..2d1fd273 100644
--- a/ecomp-portal-widget-ms/widget-ms/src/test/java/org/onap/portalapp/widget/service/impl/WidgetCatalogServiceImplTest.java
+++ b/ecomp-portal-widget-ms/widget-ms/src/test/java/org/onap/portalapp/widget/service/impl/WidgetCatalogServiceImplTest.java
@@ -59,6 +59,7 @@ import org.mockito.MockitoAnnotations;
import org.onap.portalapp.widget.domain.App;
import org.onap.portalapp.widget.domain.RoleApp;
import org.onap.portalapp.widget.domain.WidgetCatalog;
+import org.hibernate.query.NativeQuery;
public class WidgetCatalogServiceImplTest {
@@ -75,7 +76,7 @@ public class WidgetCatalogServiceImplTest {
Criteria criteria;
@Mock
- SQLQuery query;
+ NativeQuery query;
@Before
public void init() {
diff --git a/ecomp-portal-widget-ms/widget-ms/src/test/java/org/onap/portalapp/widget/test/controller/WidgetsCatalogControllerTest.java b/ecomp-portal-widget-ms/widget-ms/src/test/java/org/onap/portalapp/widget/test/controller/WidgetsCatalogControllerTest.java
index d3dc1cbf..0d01ee50 100644
--- a/ecomp-portal-widget-ms/widget-ms/src/test/java/org/onap/portalapp/widget/test/controller/WidgetsCatalogControllerTest.java
+++ b/ecomp-portal-widget-ms/widget-ms/src/test/java/org/onap/portalapp/widget/test/controller/WidgetsCatalogControllerTest.java
@@ -134,7 +134,7 @@ public class WidgetsCatalogControllerTest {
List<WidgetCatalog> list = new ArrayList<WidgetCatalog>();
WidgetCatalog widget = new WidgetCatalog();
list.add(widget);
- Mockito.when(widgetService.getWidgetCatalog()).thenReturn(list);
+ Mockito.lenient().when(widgetService.getWidgetCatalog()).thenReturn(list);
mockMvc.perform(get("/microservices/widgetCatalog/"))
.andExpect(status().isBadRequest());
@@ -148,7 +148,7 @@ public class WidgetsCatalogControllerTest {
widget.setId(1);
widget.setName("junit");
list.add(widget);
- Mockito.when(widgetService.getUserWidgetCatalog("test")).thenReturn(list);
+ Mockito.lenient().when(widgetService.getUserWidgetCatalog("test")).thenReturn(list);
String security_user = "user";
String security_pass = "password";
@@ -170,7 +170,7 @@ public class WidgetsCatalogControllerTest {
widget.setId(1);
widget.setName("junit");
list.add(widget);
- Mockito.when(widgetService.getUserWidgetCatalog("test")).thenReturn(list);
+ Mockito.lenient().when(widgetService.getUserWidgetCatalog("test")).thenReturn(list);
String security_user = "user";
String security_pass = "password";
@@ -190,7 +190,7 @@ public class WidgetsCatalogControllerTest {
@Test
public void saveWidgetCatalog_ValidAuthorization_NoError() throws Exception {
ValidationRespond respond = new ValidationRespond(true, null);
- Mockito.when(storageService.checkZipFile(any(MultipartFile.class))).thenReturn(respond);
+ Mockito.lenient().when(storageService.checkZipFile(any(MultipartFile.class))).thenReturn(respond);
String security_user = "user";
String security_pass = "password";
@@ -211,7 +211,7 @@ public class WidgetsCatalogControllerTest {
@Test
public void saveWidgetCatalog_Authorization_Error() throws Exception {
ValidationRespond respond = new ValidationRespond(true, null);
- Mockito.when(storageService.checkZipFile(any(MultipartFile.class))).thenReturn(respond);
+ Mockito.lenient().when(storageService.checkZipFile(any(MultipartFile.class))).thenReturn(respond);
String security_user = "user";
String security_pass = "password";
@@ -270,7 +270,7 @@ public class WidgetsCatalogControllerTest {
@Test
public void updateWidgetCatalogwithFiles_ValidAuthorization_NoError() throws Exception {
ValidationRespond respond = new ValidationRespond(true, null);
- Mockito.when(storageService.checkZipFile(any(MultipartFile.class))).thenReturn(respond);
+ Mockito.lenient().when(storageService.checkZipFile(any(MultipartFile.class))).thenReturn(respond);
String security_user = "user";
String security_pass = "password";
@@ -420,7 +420,7 @@ public class WidgetsCatalogControllerTest {
widget.setId(1);
widget.setName("junit");
list.add(widget);
- Mockito.when(widgetService.getWidgetsByServiceId(serviceId)).thenReturn(list);
+ Mockito.lenient().when(widgetService.getWidgetsByServiceId(serviceId)).thenReturn(list);
String security_user = "user";
String security_pass = "password";
@@ -462,7 +462,7 @@ public class WidgetsCatalogControllerTest {
String wrong_pass = "wrong";
Long widgetId = new Long(1);
byte[] bytes="Test".getBytes();
- Mockito.when(storageService.getWidgetCatalogContent(widgetId)).thenReturn(bytes);
+ Mockito.lenient().when(storageService.getWidgetCatalogContent(widgetId)).thenReturn(bytes);
ReflectionTestUtils.setField(controller, "security_user", security_user, String.class);
ReflectionTestUtils.setField(controller, "security_pass", security_pass, String.class);