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.restclient;
23 import static org.hamcrest.CoreMatchers.equalTo;
24 import static org.hamcrest.CoreMatchers.is;
25 import static org.junit.Assert.assertThat;
26 import static org.junit.Assert.fail;
28 import java.io.IOException;
29 import java.net.URISyntaxException;
30 import java.nio.file.Files;
31 import java.nio.file.Paths;
32 import java.util.List;
33 import java.util.Properties;
34 import org.junit.Ignore;
35 import org.onap.aai.babel.service.data.BabelArtifact;
36 import org.onap.aai.modelloader.config.ModelLoaderConfig;
37 import org.onap.aai.modelloader.restclient.BabelServiceClient;
40 * Local testing of the Babel service
43 public class TestBabelServiceClient {
45 // Load properties from src/test/resources
46 protected static String CONFIG_FILE = "model-loader.properties";
48 // This test requires a running Babel system. To test locally, annotate with org.junit.Test
50 public void testRestClient() throws Exception { // NOSONAR
51 Properties configProperties = new Properties();
53 configProperties.load(this.getClass().getClassLoader().getResourceAsStream(CONFIG_FILE));
54 } catch (IOException e) {
57 BabelServiceClient client = new BabelServiceClient(new ModelLoaderConfig(configProperties, "."));
58 List<BabelArtifact> result =
59 client.postArtifact(readBytesFromFile("compressedArtifacts/service-VscpaasTest-csar.csar"),
60 "service-Vscpass-Test", "1.0", "Test-Transaction-ID-BabelClient");
62 assertThat(result.size(), is(equalTo(3)));
65 private byte[] readBytesFromFile(String resourceFile) throws IOException, URISyntaxException {
66 return Files.readAllBytes(Paths.get(ClassLoader.getSystemResource(resourceFile).toURI()));