Tests coverage up and some minor bug fixes
[portal.git] / portal-BE / src / main / java / org / onap / portal / domain / dto / transport / OnboardingWidget.java
index e08d033..ccc9a78 100644 (file)
 package org.onap.portal.domain.dto.transport;
 
 import java.io.Serializable;
-import lombok.AllArgsConstructor;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Positive;
+import lombok.Builder;
 import lombok.Getter;
 import lombok.NoArgsConstructor;
 import lombok.Setter;
+import org.hibernate.validator.constraints.NotBlank;
 import org.hibernate.validator.constraints.SafeHtml;
 
 @Getter
 @Setter
+@Builder
 @NoArgsConstructor
-@AllArgsConstructor
 public class OnboardingWidget implements Serializable {
 
-       private static final long serialVersionUID = 1L;
+       private static final long serialVersionUID = 1L;
 
-       private Long id;
-       @SafeHtml
-       private String name;
-       private Long appId;
-       @SafeHtml
-       private String appName;
-       private Integer width;
-       private Integer height;
-       @SafeHtml
-       private String url;
+       private Long id;
+       @SafeHtml(message = "name may have unsafe html content")
+       private String name;
+       @NotNull(message = "appId can't be null")
+       @Min(message = "appId value must be higher than 1",value = 2)
+       private Long appId;
+       @SafeHtml(message = "appName may have unsafe html content")
+       @NotBlank(message = "appName can't be blank")
+       private String appName;
+       @Positive(message = "width must be positive number")
+       private Integer width;
+       @Positive(message = "height must be positive number")
+       private Integer height;
+       @SafeHtml(message = "url may have unsafe html content")
+       @NotBlank(message = "url can't be blank")
+       private String url;
 
-       public void normalize() {
-               this.name = (this.name == null) ? "" : this.name.trim();
-               this.appName = (this.appName == null) ? "" : this.appName.trim();
-               if (this.width == null)
-                       this.width = 0;
-               if (this.height == null)
-                       this.height = 0;
-               this.url = (this.url == null) ? "" : this.url.trim();
-       }
+       public OnboardingWidget(Long id, String name, Long appId,
+               String appName, Integer width, Integer height,
+               String url) {
+              this.id = id;
+              this.name = name;
+              this.appId = appId;
+              this.appName = appName;
+              this.width = width;
+              this.height = height;
+              this.url = url;
+       }
+
+       public void normalize() {
+              this.name = (this.name == null) ? "" : this.name.trim();
+              this.appName = (this.appName == null) ? "" : this.appName.trim();
+              if (this.width == null) {
+                     this.width = 0;
+              }
+              if (this.height == null) {
+                     this.height = 0;
+              }
+              this.url = (this.url == null) ? "" : this.url.trim();
+       }
 
 }