2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 European Software Marketing Ltd.
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.babel.csar.vnfcatalog;
23 import static org.hamcrest.CoreMatchers.equalTo;
24 import static org.hamcrest.CoreMatchers.nullValue;
25 import static org.hamcrest.MatcherAssert.assertThat;
26 import static org.hamcrest.core.Is.is;
28 import com.google.gson.Gson;
29 import com.google.gson.reflect.TypeToken;
30 import java.io.IOException;
31 import java.util.ArrayList;
32 import java.util.List;
33 import org.junit.Test;
34 import org.onap.aai.babel.service.data.BabelArtifact;
35 import org.onap.aai.babel.service.data.BabelArtifact.ArtifactType;
36 import org.onap.aai.babel.util.ArtifactTestUtils;
39 * Tests {@link ConfigurationsToBabelArtifactConverter}.
41 public class ConfigurationsToBabelArtifactConverterTest {
43 public void testNullListSupplied() {
44 assertThat(ConfigurationsToBabelArtifactConverter.convert(null), is(nullValue()));
48 public void testEmptyListSupplied() {
49 assertThat(ConfigurationsToBabelArtifactConverter.convert(new ArrayList<>()), is(nullValue()));
53 public void testValidListSupplied() throws IOException {
54 String expectedJson = new ArtifactTestUtils().getRequestJson("vnfVendorImageConfigurations.json");
55 List<VendorImageConfiguration> configurations =
56 new Gson().fromJson(expectedJson, new TypeToken<ArrayList<VendorImageConfiguration>>() {}.getType());
58 BabelArtifact artifact = ConfigurationsToBabelArtifactConverter.convert(configurations);
60 assertThat(artifact.getName(), is(equalTo("vnfVendorImageConfigurations")));
61 assertThat(artifact.getType(), is(equalTo(ArtifactType.VNFCATALOG)));
62 assertThat(artifact.getPayload(), is(equalTo(expectedJson)));