diff options
author | andre.schmid <andre.schmid@est.tech> | 2020-04-17 14:53:17 +0100 |
---|---|---|
committer | Ofir Sonsino <ofir.sonsino@intl.att.com> | 2020-04-19 16:35:32 +0000 |
commit | 615de28561aeb843e4fc18a1859b68a8164b17a4 (patch) | |
tree | e4d66d6452e1b0cd8c81dba21d76d8e56c48a8a6 /common-app-api/src/test | |
parent | cd6f933375c412c2f79a12e909821322d58a8499 (diff) |
Validates artifact configuration
Validates if all the SDC base artifacts are configured.
The base artifacts are provided by the ArtifactTypeEnum.
Change-Id: Iffa38d6ba276014940afad71f7472bc8d730fcf8
Issue-ID: SDC-2929
Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'common-app-api/src/test')
-rw-r--r-- | common-app-api/src/test/java/org/openecomp/sdc/be/config/validation/ArtifactConfigValidatorTest.java | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/be/config/validation/ArtifactConfigValidatorTest.java b/common-app-api/src/test/java/org/openecomp/sdc/be/config/validation/ArtifactConfigValidatorTest.java new file mode 100644 index 0000000000..14e679276e --- /dev/null +++ b/common-app-api/src/test/java/org/openecomp/sdc/be/config/validation/ArtifactConfigValidatorTest.java @@ -0,0 +1,76 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation + * ================================================================================ + * 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.openecomp.sdc.be.config.validation; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.openecomp.sdc.be.config.ArtifactConfiguration; +import org.openecomp.sdc.be.config.Configuration; +import org.openecomp.sdc.be.config.exception.MissingBaseArtifactConfigException; +import org.openecomp.sdc.common.api.ArtifactTypeEnum; + +public class ArtifactConfigValidatorTest { + + @Rule + public ExpectedException exceptionRule = ExpectedException.none(); + + public ArtifactConfigValidator artifactConfigValidator; + + @Test + public void testValidate() { + final Configuration configuration = new Configuration(); + //not base artifacts, should validate + artifactConfigValidator = new ArtifactConfigValidator(configuration, Collections.emptySet()); + artifactConfigValidator.validate(); + final HashSet<ArtifactTypeEnum> baseArtifactTypes = new HashSet<>( + Arrays.asList(ArtifactTypeEnum.AAI_SERVICE_MODEL, ArtifactTypeEnum.BPEL)); + //with base artifacts, but no artifact configured, should validate + artifactConfigValidator = new ArtifactConfigValidator(configuration, baseArtifactTypes); + artifactConfigValidator.validate(); + + final List<ArtifactConfiguration> artifactConfigurationList = new ArrayList<>(); + final ArtifactConfiguration artifactConfiguration1 = new ArtifactConfiguration(); + artifactConfiguration1.setType(ArtifactTypeEnum.AAI_SERVICE_MODEL.getType()); + artifactConfigurationList.add(artifactConfiguration1); + + final ArtifactConfiguration artifactConfiguration2 = new ArtifactConfiguration(); + artifactConfiguration2.setType(ArtifactTypeEnum.BPEL.getType()); + artifactConfigurationList.add(artifactConfiguration2); + + configuration.setArtifacts(artifactConfigurationList); + //with base artifacts and corresponding configuration, should validate + artifactConfigValidator = new ArtifactConfigValidator(configuration, baseArtifactTypes); + artifactConfigValidator.validate(); + + //with base artifacts and missing one configuration, should not validate + configuration.setArtifacts(Collections.singletonList(artifactConfiguration1)); + exceptionRule.expect(MissingBaseArtifactConfigException.class); + exceptionRule.expectMessage(String.format("Missing configuration for Artifact Type(s): %s", ArtifactTypeEnum.BPEL.getType())); + artifactConfigValidator = new ArtifactConfigValidator(configuration, baseArtifactTypes); + artifactConfigValidator.validate(); + } + +}
\ No newline at end of file |