Use lombok for data objects 93/96693/3
authorPamela Dragosh <pdragosh@research.att.com>
Mon, 7 Oct 2019 19:26:08 +0000 (15:26 -0400)
committerPamela Dragosh <pdragosh@research.att.com>
Mon, 7 Oct 2019 23:57:49 +0000 (19:57 -0400)
Removing lines to see if this will bump coverage. Some sonar
for Junit tests and missing coverage.

My next task will be to re-use some of this duplicate code
for these object types and the controllers.

Trailing spaces for patch #3.

Issue-ID: POLICY-2133
Change-Id: Iaee123c6be4b63bd831172340709fe7597feaa78
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopFaultController.java
POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java
POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateOptimizationController.java
POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PDPController.java
POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyRolesController.java
POLICY-SDK-APP/src/test/java/org/onap/policy/controller/PDPControllerTest.java
POLICY-SDK-APP/src/test/java/org/onap/policy/controller/PolicyRolesControllerTest.java
PolicyEngineAPI/pom.xml
pom.xml

index b88a599..f279418 100644 (file)
@@ -36,7 +36,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 import java.util.stream.IntStream;
-
+import lombok.Getter;
+import lombok.Setter;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AllOfType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType;
@@ -577,6 +578,8 @@ public class CreateClosedLoopFaultController extends RestrictedBaseController {
 }
 
 
+@Getter
+@Setter
 class ClosedLoopGridJSONData {
 
     private String clearTimeOut;
@@ -585,43 +588,4 @@ class ClosedLoopGridJSONData {
     private List<Object> connecttriggerSignatures;
     private List<Object> connectVerificationSignatures;
 
-    public String getClearTimeOut() {
-        return clearTimeOut;
-    }
-
-    public void setClearTimeOut(String clearTimeOut) {
-        this.clearTimeOut = clearTimeOut;
-    }
-
-    public String getTrapMaxAge() {
-        return trapMaxAge;
-    }
-
-    public void setTrapMaxAge(String trapMaxAge) {
-        this.trapMaxAge = trapMaxAge;
-    }
-
-    public String getVerificationclearTimeOut() {
-        return verificationclearTimeOut;
-    }
-
-    public void setVerificationclearTimeOut(String verificationclearTimeOut) {
-        this.verificationclearTimeOut = verificationclearTimeOut;
-    }
-
-    public List<Object> getConnecttriggerSignatures() {
-        return connecttriggerSignatures;
-    }
-
-    public void setConnecttriggerSignatures(List<Object> connecttriggerSignatures) {
-        this.connecttriggerSignatures = connecttriggerSignatures;
-    }
-
-    public List<Object> getConnectVerificationSignatures() {
-        return connectVerificationSignatures;
-    }
-
-    public void setConnectVerificationSignatures(List<Object> connectVerificationSignatures) {
-        this.connectVerificationSignatures = connectVerificationSignatures;
-    }
 }
index f7e5c08..2b7974d 100644 (file)
@@ -69,7 +69,8 @@ import javax.json.JsonReader;
 import javax.json.JsonValue;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-
+import lombok.Getter;
+import lombok.Setter;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AllOfType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType;
@@ -1737,6 +1738,8 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
 }
 
 
+@Getter
+@Setter
 class DCAEMicroServiceObject {
 
     private String service;
@@ -1753,127 +1756,5 @@ class DCAEMicroServiceObject {
     private String riskLevel;
     private String guard = null;
     private Object uiContent;
-
-    public String getGuard() {
-        return guard;
-    }
-
-    public void setGuard(String guard) {
-        this.guard = guard;
-    }
-
-    public String getRiskType() {
-        return riskType;
-    }
-
-    public void setRiskType(String riskType) {
-        this.riskType = riskType;
-    }
-
-    public String getRiskLevel() {
-        return riskLevel;
-    }
-
-    public void setRiskLevel(String riskLevel) {
-        this.riskLevel = riskLevel;
-    }
-
-    public String getPolicyScope() {
-        return policyScope;
-    }
-
-    public void setPolicyScope(String policyScope) {
-        this.policyScope = policyScope;
-    }
-
-    public String getPriority() {
-        return priority;
-    }
-
-    public void setPriority(String priority) {
-        this.priority = priority;
-    }
-
-    public String getVersion() {
-        return version;
-    }
-
-    public void setVersion(String version) {
-        this.version = version;
-    }
-
     private Object content;
-
-    public String getPolicyName() {
-        return policyName;
-    }
-
-    public void setPolicyName(String policyName) {
-        this.policyName = policyName;
-    }
-
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    public String getConfigName() {
-        return configName;
-    }
-
-    public void setConfigName(String configName) {
-        this.configName = configName;
-    }
-
-    public Object getContent() {
-        return content;
-    }
-
-    public void setContent(Object content) {
-        this.content = content;
-    }
-
-    public String getService() {
-        return service;
-    }
-
-    public void setService(String service) {
-        this.service = service;
-    }
-
-    public String getLocation() {
-        return location;
-    }
-
-    public void setLocation(String location) {
-        this.location = location;
-    }
-
-    public String getUuid() {
-        return uuid;
-    }
-
-    public void setUuid(String uuid) {
-        this.uuid = uuid;
-    }
-
-    public String getTemplateVersion() {
-        return templateVersion;
-    }
-
-    public void setTemplateVersion(String templateVersion) {
-        this.templateVersion = templateVersion;
-    }
-
-    public Object getUiContent() {
-        return uiContent;
-    }
-
-    public void setUiContent(Object uiContent) {
-        this.uiContent = uiContent;
-    }
-
 }
index 719c668..b77f6a7 100644 (file)
@@ -52,7 +52,8 @@ import java.util.zip.ZipFile;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-
+import lombok.Getter;
+import lombok.Setter;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AllOfType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType;
@@ -893,7 +894,8 @@ public class CreateOptimizationController extends RestrictedBaseController {
     }
 }
 
-
+@Getter
+@Setter
 class OptimizationObject {
 
     private String service;
@@ -906,95 +908,5 @@ class OptimizationObject {
     private String riskType;
     private String riskLevel;
     private String guard = null;
-
-    public String getGuard() {
-        return guard;
-    }
-
-    public void setGuard(String guard) {
-        this.guard = guard;
-    }
-
-    public String getRiskType() {
-        return riskType;
-    }
-
-    public void setRiskType(String riskType) {
-        this.riskType = riskType;
-    }
-
-    public String getRiskLevel() {
-        return riskLevel;
-    }
-
-    public void setRiskLevel(String riskLevel) {
-        this.riskLevel = riskLevel;
-    }
-
-    public String getPriority() {
-        return priority;
-    }
-
-    public void setPriority(String priority) {
-        this.priority = priority;
-    }
-
-    public String getPolicyScope() {
-        return policyScope;
-    }
-
-    public void setPolicyScope(String policyScope) {
-        this.policyScope = policyScope;
-    }
-
-    public String getVersion() {
-        return version;
-    }
-
-    public void setVersion(String version) {
-        this.version = version;
-    }
-
     private Object content;
-
-    public String getPolicyName() {
-        return policyName;
-    }
-
-    public void setPolicyName(String policyName) {
-        this.policyName = policyName;
-    }
-
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    public Object getContent() {
-        return content;
-    }
-
-    public void setContent(Object content) {
-        this.content = content;
-    }
-
-    public String getService() {
-        return service;
-    }
-
-    public void setService(String service) {
-        this.service = service;
-    }
-
-    public String getTemplateVersion() {
-        return templateVersion;
-    }
-
-    public void setTemplateVersion(String templateVersion) {
-        this.templateVersion = templateVersion;
-    }
-
 }
index 24fade1..56d882f 100644 (file)
@@ -37,7 +37,8 @@ import java.util.Set;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-
+import lombok.Getter;
+import lombok.Setter;
 import org.json.JSONObject;
 import org.onap.policy.admin.RESTfulPAPEngine;
 import org.onap.policy.common.logging.flexlogger.FlexLogger;
@@ -409,43 +410,11 @@ public class PDPController extends RestrictedBaseController {
     }
 }
 
-
+@Getter
+@Setter
 class PdpData {
     String id;
     int jmxPort;
     String name;
     String description;
-
-    public String getId() {
-        return id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    public int getJmxPort() {
-        return jmxPort;
-    }
-
-    public void setJmxPort(int jmxPort) {
-        this.jmxPort = jmxPort;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
 }
index 29fdecd..f416386 100644 (file)
@@ -34,7 +34,8 @@ import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-
+import lombok.Getter;
+import lombok.Setter;
 import org.json.JSONObject;
 import org.onap.policy.common.logging.flexlogger.FlexLogger;
 import org.onap.policy.common.logging.flexlogger.Logger;
@@ -191,43 +192,11 @@ public class PolicyRolesController extends RestrictedBaseController {
     }
 }
 
-
+@Setter
+@Getter
 class ReadScopes {
     private int id;
     private UserInfo loginId;
     private String role;
     private List<String> scope;
-
-    public int getId() {
-        return id;
-    }
-
-    public void setId(int id) {
-        this.id = id;
-    }
-
-    public UserInfo getLoginId() {
-        return loginId;
-    }
-
-    public void setLoginId(UserInfo loginId) {
-        this.loginId = loginId;
-    }
-
-    public String getRole() {
-        return role;
-    }
-
-    public void setRole(String role) {
-        this.role = role;
-    }
-
-    public List<String> getScope() {
-        return scope;
-    }
-
-    public void setScope(List<String> scope) {
-        this.scope = scope;
-    }
-
 }
index 0d5a097..372090f 100644 (file)
@@ -22,6 +22,7 @@
 
 package org.onap.policy.controller;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 import java.io.UnsupportedEncodingException;
@@ -50,6 +51,11 @@ public class PDPControllerTest extends Mockito {
     private Set<StdPDPGroup> groups;
     private static List<Object> rolesdata;
 
+    /**
+     * Before.
+     *
+     * @throws Exception Exception
+     */
     @Before
     public void setUp() throws Exception {
         logger.info("setUp: Entering");
@@ -79,9 +85,9 @@ public class PDPControllerTest extends Mockito {
     }
 
     @Test
-    public void testPDPGroupData() {
-        HttpServletRequest request = mock(HttpServletRequest.class);
-        MockHttpServletResponse response = new MockHttpServletResponse();
+    public void testPdpGroupData() {
+        final HttpServletRequest request = mock(HttpServletRequest.class);
+        final MockHttpServletResponse response = new MockHttpServletResponse();
         PolicyController controller = mock(PolicyController.class);
         PDPController pdpController = new PDPController();
         pdpController.setJunit(true);;
@@ -95,4 +101,17 @@ public class PDPControllerTest extends Mockito {
             logger.error("Exception Occured" + e);
         }
     }
+
+    @Test
+    public void testPdpData() {
+        PdpData data = new PdpData();
+        data.setId("id");
+        assertEquals("id", data.getId());
+        data.setDescription("foo");
+        assertEquals("foo", data.getDescription());
+        data.setJmxPort(0);
+        assertEquals(0, data.getJmxPort());
+        data.setName("name");
+        assertEquals("name", data.getName());
+    }
 }
index 720f6ca..e245256 100644 (file)
@@ -51,6 +51,11 @@ public class PolicyRolesControllerTest {
     private PolicyRolesController controller = null;
     private static CommonClassDao commonClassDao;
 
+    /**
+     * Before.
+     *
+     * @throws Exception exception
+     */
     @Before
     public void setUp() throws Exception {
         logger.info("setUp: Entering");
index 49c5494..6bde8fb 100644 (file)
@@ -3,14 +3,14 @@
   ============LICENSE_START=======================================================
   ONAP Policy Engine
   ================================================================================
-  Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+  Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
   ================================================================================
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file 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.
                 </exclusion>
             </exclusions>
         </dependency>
-        <dependency>
-             <groupId>org.projectlombok</groupId>
-             <artifactId>lombok</artifactId>
-             <version>1.18.6</version>
-             <scope>provided</scope>
-        </dependency>
         <dependency>
             <groupId>org.onap.policy.engine</groupId>
             <artifactId>ONAP-XACML</artifactId>
diff --git a/pom.xml b/pom.xml
index d5d1fa4..368e3cf 100644 (file)
--- a/pom.xml
+++ b/pom.xml
         </plugins>
     </reporting>
     <dependencies>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <scope>provided</scope>
+        </dependency>
         <dependency>
             <groupId>javax.servlet</groupId>
             <artifactId>javax.servlet-api</artifactId>

© 2017 ONAP. Copyright © The Linux Foundation ®. All Rights Reserved.
The Linux Foundation has registered trademarks and uses trademarks.
For a list of trademarks of The Linux Foundation, please see our Trademark Usage page.
Linux is a registered trademark of Linus Torvalds.
Privacy Policy and Terms of Use