2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
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.ccsdk.sli.adaptors.aai;
24 import static org.junit.Assert.assertNotNull;
26 import java.io.UnsupportedEncodingException;
27 import java.net.MalformedURLException;
28 import java.net.URISyntaxException;
31 import org.junit.AfterClass;
32 import org.junit.BeforeClass;
33 import org.junit.FixMethodOrder;
34 import org.junit.Test;
35 import org.junit.runners.MethodSorters;
36 import org.onap.ccsdk.sli.adaptors.aai.data.AAIDatum;
37 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
38 import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
39 import org.slf4j.Logger;
40 import org.slf4j.LoggerFactory;
42 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
43 public class EchoRequestTest {
45 private static final Logger LOG = LoggerFactory.getLogger(EchoRequestTest.class);
47 private static EchoRequest request;
48 private static AAIService aaiService;
51 public static void setUp() throws Exception {
52 aaiService = new AAIService(
53 AAIService.class.getResource(AAIService.AAICLIENT_PROPERTIES));
54 request = new EchoRequest();
55 LOG.info("\nEchoRequestTest.setUp\n");
59 public static void tearDown() throws Exception {
61 LOG.info("----------------------- EchoRequestTest.tearDown -----------------------");
65 public void runGetRequestUrlTest() {
66 LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
70 url = request.getRequestUrl("GET", null);
72 } catch (UnsupportedEncodingException | MalformedURLException exc) {
73 LOG.error("Failed test", exc);
79 public void runToJSONStringTest() {
80 LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
83 String json = request.toJSONString();
85 } catch (Exception exc) {
86 LOG.error("Failed test", exc);
92 public void runGetArgsListTest() {
93 LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
96 String[] args = request.getArgsList();
98 } catch (Exception exc) {
99 LOG.error("Failed test", exc);
105 public void runGetModelTest() {
106 LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
109 Class<? extends AAIDatum> clazz = request.getModelClass();
110 assertNotNull(clazz);
111 } catch (Exception exc) {
112 LOG.error("Failed test", exc);
118 public void EchoTest() {
119 LOG.info("----------------------- Test: " + new Object(){}.getClass().getEnclosingMethod().getName() + " -----------------------");
122 SvcLogicContext ctx = new SvcLogicContext();
124 QueryStatus resp = null;
126 // (String resource, boolean localOnly, String select, String key, String prefix, String orderBy, SvcLogicContext ctx)
127 resp = aaiService.query("echo", false, null, "", "aaidata", null, ctx);
128 assert(resp == QueryStatus.SUCCESS);
132 LOG.error("Caught exception", e);
133 // fail("Caught exception");