Revisions made to the Model Loader to use Babel
[aai/model-loader.git] / src / test / java / org / onap / aai / modelloader / fixture / ArtifactInfoBuilder.java
1 /**
2  * ============LICENSE_START==========================================
3  * org.onap.aai
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
11  *
12  *        http://www.apache.org/licenses/LICENSE-2.0
13  *
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============================================
20  */
21 package org.onap.aai.modelloader.fixture;
22
23 import java.util.ArrayList;
24 import java.util.List;
25
26 import org.onap.aai.modelloader.service.ArtifactInfoImpl;
27 import org.openecomp.sdc.api.notification.IArtifactInfo;
28
29 /**
30  * This class builds an instance of IArtifactInfo for test purposes.
31  */
32 public class ArtifactInfoBuilder {
33
34     /**
35      * Builds an implementation of IArtifactInfo for test purposes.
36      * <p/>
37      *
38      * @param type type of artifact
39      * @param name name of artifact
40      * @param description description of artifact
41      * @param version version of artifact
42      * @return IArtifactInfo implementation of IArtifactInfo from given parameters for test purposes
43      */
44     public static IArtifactInfo build(final String type, final String name, final String description,
45             final String version) {
46         IArtifactInfo artifact = new ArtifactInfoImpl();
47
48         ((ArtifactInfoImpl) artifact).setArtifactType(type);
49         ((ArtifactInfoImpl) artifact).setArtifactName(name);
50         ((ArtifactInfoImpl) artifact).setArtifactDescription(description);
51         ((ArtifactInfoImpl) artifact).setArtifactVersion(version);
52
53         return artifact;
54     }
55
56     /**
57      * This method is responsible for building a collection of artifacts from a given set of info.
58      * <p/>
59      * The info supplied is a two dimensional array with each element of the first dimension representing a single
60      * artifact and each element of the second dimension represents a property of the artifact.
61      * <p/>
62      * The method will call {@link #build(String, String, String, String)} to build each element in the first dimension
63      * where the elements of the second dimension are the arguments to {@link #build(String, String, String, String)}.
64      * <p/>
65      *
66      * @param artifactInfoBits a two dimensional array of data used to build the artifacts
67      * @return List<IArtifactInfo> a list of artifacts built from the given array of info
68      */
69     static List<IArtifactInfo> buildArtifacts(final String[][] artifactInfoBits) {
70         List<IArtifactInfo> artifacts = new ArrayList<>();
71
72         for (String[] artifactInfoBit : artifactInfoBits) {
73             artifacts.add(build(artifactInfoBit[0], artifactInfoBit[1], artifactInfoBit[2], artifactInfoBit[3]));
74         }
75
76         return artifacts;
77     }
78 }