diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2018-08-13 17:38:46 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-08-13 17:38:46 +0000 |
commit | 635cde469ace4c7d60ba87bc0f9e4b26db59a1d1 (patch) | |
tree | 7ad57cf81a91286fed1d4c9aa8b4f5f684363360 /plugins/reception-plugins/src/test | |
parent | 550d0d986713f4da7b37b8f2b16264884c05b9ab (diff) | |
parent | 6261a6058cba8f5c0da0be36067ce1c6223c5ffc (diff) |
Merge "Initial moduel structure for SDC handling"
Diffstat (limited to 'plugins/reception-plugins/src/test')
3 files changed, 131 insertions, 0 deletions
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/PSSDConfigurationTest.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/PSSDConfigurationTest.java new file mode 100644 index 00000000..bcb7ac80 --- /dev/null +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/PSSDConfigurationTest.java @@ -0,0 +1,79 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Intel. 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.distribution.reception.handling.sdc; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import org.junit.Test; +import org.onap.policy.common.parameters.GroupValidationResult; + +/*- + * Tests for PSSDConfiguration class + * + */ +public class PSSDConfigurationTest { + + @Test + public void testPSSDConfigurationParametersGroup() throws IOException { + PSSDConfigurationParametersGroup configParameters = null; + try { + final Gson gson = new GsonBuilder().create(); + configParameters = + gson.fromJson(new FileReader("src/test/resources/handling-sdc.json"), + PSSDConfigurationParametersGroup.class); + } catch (final Exception e) { + fail("test should not thrown an exception here: " + e.getMessage()); + } + final GroupValidationResult validationResult = configParameters.validate(); + assertTrue(validationResult.isValid()); + assertEquals("parameterConfig1", configParameters.getName()); + + PSSDConfiguration config = new PSSDConfiguration(configParameters); + assertEquals(20, config.getPollingInterval()); + assertEquals(30,config.getPollingTimeout()); + } + + @Test + public void testInvalidPSSDConfigurationParametersGroup() throws IOException { + PSSDConfigurationParametersGroup configParameters = null; + try { + final Gson gson = new GsonBuilder().create(); + configParameters = + gson.fromJson(new FileReader("src/test/resources/handling-sdcInvalid.json"), + PSSDConfigurationParametersGroup.class); + } catch (final Exception e) { + fail("test should not thrown an exception here: " + e.getMessage()); + } + final GroupValidationResult validationResult = configParameters.validate(); + assertFalse(validationResult.isValid()); + assertEquals("parameterConfig1", configParameters.getName()); + + } +} diff --git a/plugins/reception-plugins/src/test/resources/handling-sdc.json b/plugins/reception-plugins/src/test/resources/handling-sdc.json new file mode 100644 index 00000000..c1ca23aa --- /dev/null +++ b/plugins/reception-plugins/src/test/resources/handling-sdc.json @@ -0,0 +1,26 @@ +{ + "name" : "parameterConfig1", + "asdcAddress": "localhost", + "messageBusAddress": [ + "a.com", + "b.com", + "c.com" + ], + "user": "tbdsdc-1480", + "password": "tbdsdc-1480", + "pollingInterval":20, + "pollingTimeout":30, + "consumerId": "policy-id", + "artifactTypes": [ + "TOSCA_CSAR", + "HEAT" + ], + "consumerGroup": "policy-group", + "environmentName": "environmentName", + "keystorePath": "null", + "keystorePassword": "null", + "activeserverTlsAuth": false, + "isFilterinEmptyResources": true, + "isUseHttpsWithDmaap": false +} + diff --git a/plugins/reception-plugins/src/test/resources/handling-sdcInvalid.json b/plugins/reception-plugins/src/test/resources/handling-sdcInvalid.json new file mode 100644 index 00000000..ababea48 --- /dev/null +++ b/plugins/reception-plugins/src/test/resources/handling-sdcInvalid.json @@ -0,0 +1,26 @@ +{ + "name" : "parameterConfig1", + "asdcAddress": "localhost", + "messageBusAddress": [ + "a.com", + "b.com", + "c.com" + ], + "user": "tbdsdc-1480", + "password": "tbdsdc-1480", + "pollingInterval":-1, + "pollingTimeout":-2, + "consumerId": "policy-id", + "artifactTypes": [ + "TOSCA_CSAR", + "HEAT" + ], + "consumerGroup": "policy-group", + "environmentName": "environmentName", + "keystorePath": "null", + "keystorePassword": "null", + "activeserverTlsAuth": false, + "isFilterinEmptyResources": true, + "isUseHttpsWithDmaap": false +} + |