2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 Amdocs
7 * ===================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
21 package org.onap.aai.modelloader.extraction;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertTrue;
25 import static org.onap.aai.modelloader.fixture.NotificationDataFixtureBuilder.getEmptyNotificationData;
26 import static org.onap.aai.modelloader.fixture.NotificationDataFixtureBuilder.getNotificationDataWithOneResource;
27 import static org.onap.aai.modelloader.fixture.NotificationDataFixtureBuilder.getNotificationDataWithOneService;
28 import static org.onap.aai.modelloader.fixture.NotificationDataFixtureBuilder.getNotificationDataWithOneServiceAndResources;
30 import java.util.ArrayList;
31 import java.util.List;
32 import org.junit.After;
33 import org.junit.Before;
34 import org.junit.Test;
35 import org.onap.aai.modelloader.extraction.ArtifactInfoExtractor;
36 import org.onap.aai.modelloader.fixture.ArtifactInfoBuilder;
37 import org.onap.aai.modelloader.fixture.TestNotificationDataImpl;
38 import org.openecomp.sdc.api.notification.IArtifactInfo;
39 import org.openecomp.sdc.api.notification.INotificationData;
42 * Tests {@link ArtifactInfoExtractor}
44 public class ArtifactInfoExtractorTest {
46 private ArtifactInfoExtractor extractor;
50 extractor = new ArtifactInfoExtractor();
54 public void tearDown() {
59 public void extract_nullDataSupplied() {
60 doEmptyArtifactsTest(null);
63 private void doEmptyArtifactsTest(INotificationData notificationData) {
64 assertTrue("The list returned should have been empty", extractor.extract(notificationData).isEmpty());
68 public void extract_dataHasNullArtifacts() {
69 doEmptyArtifactsTest(new TestNotificationDataImpl());
73 public void extract_dataHasNoArtifacts() {
74 doEmptyArtifactsTest(getEmptyNotificationData());
78 public void dataHasOneServiceArtifact() {
79 IArtifactInfo expected = ArtifactInfoBuilder.build("S", "service", "description of service", "s1.0");
81 List<IArtifactInfo> artifacts = extractor.extract(getNotificationDataWithOneService());
83 assertTrue("One artifact should have been returned", artifacts.size() == 1);
84 assertEquals("The actual artifact did not match the expected one", expected, artifacts.get(0));
88 public void dataHasOneResourceArtifact() {
89 List<IArtifactInfo> expectedArtifacts = new ArrayList<>();
90 expectedArtifacts.add(ArtifactInfoBuilder.build("R", "resource", "description of resource", "r1.0"));
92 List<IArtifactInfo> artifacts = extractor.extract(getNotificationDataWithOneResource());
94 assertTrue("One artifact should have been returned", artifacts.size() == 1);
95 assertEquals("The actual artifact did not match the expected one", expectedArtifacts, artifacts);
99 public void dataHasOneServiceAndTwoResources() {
100 List<IArtifactInfo> expectedArtifacts = new ArrayList<>();
101 expectedArtifacts.add(ArtifactInfoBuilder.build("TOSCA_CSAR", "service", "description of service", "s1.0"));
102 expectedArtifacts.add(ArtifactInfoBuilder.build("TOSCA_CSAR", "resource", "description of resource", "r1.0"));
104 List<IArtifactInfo> artifacts = extractor.extract(getNotificationDataWithOneServiceAndResources());
106 assertTrue("One artifact should have been returned", artifacts.size() == 2);
107 assertEquals("The actual artifact did not match the expected one", expectedArtifacts, artifacts);