Moving @NotNull annotation to field level 09/126109/2
authorlapentafd <francesco.lapenta@est.tech>
Tue, 7 Dec 2021 15:59:49 +0000 (15:59 +0000)
committerlapentafd <francesco.lapenta@est.tech>
Wed, 8 Dec 2021 11:07:03 +0000 (11:07 +0000)
KeyStorePassword and KeyStorePath values
can be expressed as simply null instead of "null"

Issue-ID: POLICY-3604
Change-Id: I839bce33df4829fcc8d604f8ed1e52e6f50ef988
Signed-off-by: lapentafd <francesco.lapenta@est.tech>
plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerConfigurationParameterGroup.java
plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandlerConfigurationParameterGroup.java
plugins/reception-plugins/src/test/resources/handling-sdc-null-parameters.json [new file with mode: 0644]

index 942aa8d..7964aa1 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2018 Intel. All rights reserved.
- *  Modifications Copyright (C) 2019 Nordix Foundation.
+ *  Modifications Copyright (C) 2019-2021 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -32,21 +32,18 @@ import org.onap.policy.distribution.reception.parameters.ReceptionHandlerConfigu
  * format, which strictly adheres to the interface:IConfiguration, defined by SDC SDK.
  */
 @Getter
-@NotNull
-@NotBlank
 public class SdcReceptionHandlerConfigurationParameterGroup extends ReceptionHandlerConfigurationParameterGroup {
-
-    private String asdcAddress;
-    private List<String> messageBusAddress;
-    private String user;
-    private String password;
-    private int pollingInterval;
-    private int pollingTimeout;
-    private int retryDelay;
-    private String consumerId;
-    private List<String> artifactTypes;
-    private String consumerGroup;
-    private String environmentName;
+    private @NotNull @NotBlank String asdcAddress;
+    private @NotNull @NotBlank List<String> messageBusAddress;
+    private @NotNull @NotBlank String user;
+    private @NotNull @NotBlank String password;
+    private @NotNull @NotBlank int pollingInterval;
+    private @NotNull @NotBlank int pollingTimeout;
+    private @NotNull @NotBlank int retryDelay;
+    private @NotNull @NotBlank String consumerId;
+    private @NotNull @NotBlank List<String> artifactTypes;
+    private @NotNull @NotBlank String consumerGroup;
+    private @NotNull @NotBlank String environmentName;
     private String keyStorePath;
     private String keyStorePassword;
     private boolean activeServerTlsAuth;
@@ -57,4 +54,3 @@ public class SdcReceptionHandlerConfigurationParameterGroup extends ReceptionHan
         super(SdcReceptionHandlerConfigurationParameterGroup.class.getSimpleName());
     }
 }
-
index cd7f261..06f6d9e 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2018 Intel. All rights reserved.
- *  Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ *  Modifications Copyright (C) 2019-2021 Nordix Foundation.
  *  Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -68,6 +68,24 @@ public class TestSdcReceptionHandlerConfigurationParameterGroup {
         assertEquals(false, config.isUseHttpsWithDmaap());
     }
 
+    @Test
+    public void testSdcConfigurationNullParameters() throws IOException {
+        SdcReceptionHandlerConfigurationParameterGroup configParameters = null;
+        final Gson gson = new GsonBuilder().create();
+        configParameters = gson.fromJson(new FileReader("src/test/resources/handling-sdc-null-parameters.json"),
+               SdcReceptionHandlerConfigurationParameterGroup.class);
+
+        final ValidationResult validationResult = configParameters.validate();
+        assertTrue(validationResult.isValid());
+        final SdcConfiguration config = new SdcConfiguration(configParameters);
+        assertEquals(null, config.getKeyStorePath());
+        assertEquals(null, config.getKeyStorePassword());
+        //if boolean parameters are null they are set to false
+        assertEquals(false, config.activateServerTLSAuth());
+        assertEquals(false, config.isFilterInEmptyResources());
+        assertEquals(false, config.isUseHttpsWithDmaap());
+    }
+
     @Test
     public void testInvalidSdcConfiguration() throws IOException {
         SdcReceptionHandlerConfigurationParameterGroup configParameters = null;
diff --git a/plugins/reception-plugins/src/test/resources/handling-sdc-null-parameters.json b/plugins/reception-plugins/src/test/resources/handling-sdc-null-parameters.json
new file mode 100644 (file)
index 0000000..6c9301a
--- /dev/null
@@ -0,0 +1,27 @@
+{
+    "name" : "parameterConfig1",
+    "asdcAddress": "localhost",
+    "messageBusAddress": [
+        "a.com",
+        "b.com",
+        "c.com"
+    ],
+    "user": "policy",
+    "password": "policy",
+    "pollingInterval":20,
+    "pollingTimeout":30,
+    "retryDelay":30,
+    "consumerId": "policy-id",
+    "artifactTypes": [
+        "TOSCA_CSAR",
+        "HEAT"
+    ],
+    "consumerGroup": "policy-group",
+    "environmentName": "TEST",
+    "keyStorePath": null,
+    "keyStorePassword": null,
+    "activeServerTlsAuth": null,
+    "isFilterInEmptyResources": null,
+    "isUseHttpsWithDmaap": null
+}
+