2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (c) 2017-2019 AT&T Intellectual Property. All rights reserved.
6 * Copyright (c) 2017-2019 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=========================================================
22 package org.onap.aai.babel.csar.vnfcatalog;
24 import static org.hamcrest.CoreMatchers.equalTo;
25 import static org.hamcrest.CoreMatchers.is;
26 import static org.hamcrest.CoreMatchers.nullValue;
27 import static org.hamcrest.MatcherAssert.assertThat;
29 import com.google.gson.Gson;
30 import com.google.gson.reflect.TypeToken;
31 import java.io.IOException;
32 import java.util.ArrayList;
33 import java.util.List;
34 import org.junit.jupiter.api.Test;
35 import org.onap.aai.babel.service.data.BabelArtifact;
36 import org.onap.aai.babel.service.data.BabelArtifact.ArtifactType;
37 import org.onap.aai.babel.util.ArtifactTestUtils;
40 * Tests {@link ConfigurationsToBabelArtifactConverter}.
42 public class ConfigurationsToBabelArtifactConverterTest {
44 public void testNullListSupplied() {
45 assertThat(ConfigurationsToBabelArtifactConverter.convert(null), is(nullValue()));
49 public void testEmptyListSupplied() {
50 assertThat(ConfigurationsToBabelArtifactConverter.convert(new ArrayList<>()), is(nullValue()));
54 public void testValidListSupplied() throws IOException {
55 String expectedJson = new ArtifactTestUtils().getRequestJson("vnfVendorImageConfigurations.json");
56 List<VendorImageConfiguration> configurations =
57 new Gson().fromJson(expectedJson, new TypeToken<ArrayList<VendorImageConfiguration>>() {}.getType());
59 BabelArtifact artifact = ConfigurationsToBabelArtifactConverter.convert(configurations);
61 assertThat(artifact.getName(), is(equalTo("vnfVendorImageConfigurations")));
62 assertThat(artifact.getType(), is(equalTo(ArtifactType.VNFCATALOG)));
63 assertThat(artifact.getPayload(), is(equalTo(expectedJson)));