summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-BE-common
diff options
context:
space:
mode:
authorManoop Talasila <talasila@research.att.com>2019-07-09 15:24:10 +0000
committerGerrit Code Review <gerrit@onap.org>2019-07-09 15:24:10 +0000
commit61a29dbca11ac31c40ba6022a1711f4074814df3 (patch)
tree56238bdda2dbc45d21a10a95d1b37a2573a359ff /ecomp-portal-BE-common
parenta1db0d8fc1a98c8e22879059400d218402b82925 (diff)
parentd86b4b4fc44fd3f4b24c09d784889b8b71d540e4 (diff)
Merge "CommonWidget class DB constraints"
Diffstat (limited to 'ecomp-portal-BE-common')
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/CommonWidget.java77
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/DashboardSearchResultControllerTest.java8
2 files changed, 18 insertions, 67 deletions
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/CommonWidget.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/CommonWidget.java
index 3fbdc3e8..90277877 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/CommonWidget.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/CommonWidget.java
@@ -44,6 +44,11 @@ import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
import org.hibernate.validator.constraints.SafeHtml;
import org.onap.portalsdk.core.domain.support.DomainVo;
import com.fasterxml.jackson.annotation.JsonInclude;
@@ -54,6 +59,9 @@ import com.fasterxml.jackson.annotation.JsonInclude;
@Entity
@Table(name="fn_common_widget_data")
@JsonInclude(JsonInclude.Include.NON_NULL)
+@NoArgsConstructor
+@Getter
+@Setter
public class CommonWidget extends DomainVo{
private static final long serialVersionUID = 7897021982887364557L;
@@ -64,22 +72,28 @@ public class CommonWidget extends DomainVo{
private Long id;
@Column(name = "category")
+ @Size(max = 32)
@SafeHtml
public String category;
@Column(name = "href")
+ @Size(max = 512)
@SafeHtml
public String href;
@Column(name = "title")
+ @Size(max = 256)
@SafeHtml
public String title;
@Column(name = "content")
+ @Size(max = 4096)
@SafeHtml
public String content;
@Column(name = "event_date")
+ @Size(max = 10)
+ @Pattern(regexp = "([1-2][0-9]{3})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])")
@SafeHtml
public String eventDate;
@@ -87,10 +101,6 @@ public class CommonWidget extends DomainVo{
public Integer sortOrder;
- public CommonWidget(){
-
- }
-
public CommonWidget(String category, String href, String title, String content, String eventDate, Integer sortOrder){
this.category = category;
this.href = href;
@@ -100,63 +110,4 @@ public class CommonWidget extends DomainVo{
this.sortOrder = sortOrder;
}
- public String getCategory() {
- return category;
- }
-
- public void setCategory(String category) {
- this.category = category;
- }
-
- public String getHref() {
- return href;
- }
-
- public void setHref(String href) {
- this.href = href;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public Integer getSortOrder() {
- return sortOrder;
- }
-
- public void setSortOrder(Integer sortOrder) {
- this.sortOrder = sortOrder;
- }
-
- public static long getSerialversionuid() {
- return serialVersionUID;
- }
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getContent() {
- return content;
- }
-
- public void setContent(String content) {
- this.content = content;
- }
-
- public String getEventDate() {
- return eventDate;
- }
-
- public void setEventDate(String eventDate) {
- this.eventDate = eventDate;
- }
}
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/DashboardSearchResultControllerTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/DashboardSearchResultControllerTest.java
index 34667853..c905e8d1 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/DashboardSearchResultControllerTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/DashboardSearchResultControllerTest.java
@@ -182,8 +182,8 @@ public class DashboardSearchResultControllerTest {
@Test
public void saveWidgetDataBulkIfCategoryNullTest() {
PortalRestResponse<String> ecpectedPortalRestResponse = new PortalRestResponse<>();
- ecpectedPortalRestResponse.setMessage("java.text.ParseException: Unparseable date: \"1\"");
- ecpectedPortalRestResponse.setResponse(null);
+ ecpectedPortalRestResponse.setMessage("ERROR");
+ ecpectedPortalRestResponse.setResponse("Category is not valid");
ecpectedPortalRestResponse.setStatus(PortalRestStatusEnum.ERROR);
CommonWidgetMeta commonWidgetMeta = new CommonWidgetMeta();
@@ -280,8 +280,8 @@ public class DashboardSearchResultControllerTest {
@Test
public void saveWidgetDataDateErrorTest() {
PortalRestResponse<String> ecpectedPortalRestResponse = new PortalRestResponse<>();
- ecpectedPortalRestResponse.setMessage("java.text.ParseException: Unparseable date: \"1\"");
- ecpectedPortalRestResponse.setResponse(null);
+ ecpectedPortalRestResponse.setMessage("ERROR");
+ ecpectedPortalRestResponse.setResponse("Category is not valid");
ecpectedPortalRestResponse.setStatus(PortalRestStatusEnum.ERROR);
CommonWidget commonWidget = new CommonWidget();
commonWidget.setId((long) 1);