Default TopicParams.isManaged to true 47/92147/2
authorJim Hahn <jrh3@att.com>
Sat, 27 Jul 2019 11:53:24 +0000 (07:53 -0400)
committerJim Hahn <jrh3@att.com>
Sat, 27 Jul 2019 11:53:24 +0000 (07:53 -0400)
Modified TopicParams to set "managed" to true by default.

Change-Id: Ia21caba2b882199f1a63d40b0fed1167ccb93142
Issue-ID: POLICY-1744
Signed-off-by: Jim Hahn <jrh3@att.com>
policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/TopicParameters.java
policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroupTest.java

index d525aaf..9404244 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
+ *  Modifications Copyright (C) 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.
@@ -39,4 +40,9 @@ import org.onap.policy.common.parameters.annotations.NotNull;
 @EqualsAndHashCode(callSuper = false)
 public class TopicParameters extends BusTopicParams {
     private String topicCommInfrastructure;
+
+    public TopicParameters() {
+        // this defaults to true
+        setManaged(true);
+    }
 }
index db200c8..e288009 100644 (file)
@@ -2,7 +2,6 @@
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
  *  Modifications Copyright (C) 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.
@@ -33,6 +32,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.junit.Test;
 import org.onap.policy.common.parameters.GroupValidationResult;
 import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.common.utils.coder.StandardCoder;
 
 /**
@@ -45,13 +45,20 @@ public class TopicParameterGroupTest {
     private static final Coder coder = new StandardCoder();
 
     @Test
-    public void test() {
+    public void test() throws CoderException {
         final TopicParameterGroup topicParameterGroup =
                 testData.toObject(testData.getTopicParameterGroupMap(false), TopicParameterGroup.class);
         final GroupValidationResult validationResult = topicParameterGroup.validate();
         assertTrue(validationResult.isValid());
         assertEquals(CommonTestData.TOPIC_PARAMS, topicParameterGroup.getTopicSinks());
         assertEquals(CommonTestData.TOPIC_PARAMS, topicParameterGroup.getTopicSources());
+
+        // these should default to true
+        assertTrue(new TopicParameters().isManaged());
+        assertTrue(coder.decode("{}", TopicParameters.class).isManaged());
+
+        // but can be overridden
+        assertFalse(coder.decode("{'managed':false}".replace('\'', '"'), TopicParameters.class).isManaged());
     }
 
     @Test