2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
25 package org.onap.appc.simulator.client.impl;
27 import com.fasterxml.jackson.databind.JsonNode;
28 import com.fasterxml.jackson.databind.ObjectMapper;
29 import org.apache.commons.io.filefilter.WildcardFileFilter;
30 import org.junit.Assert;
31 import org.junit.Before;
32 import org.junit.Ignore;
33 import org.junit.Test;
34 import org.junit.runner.RunWith;
35 import org.mockito.Matchers;
36 import org.mockito.Mockito;
37 import org.mockito.runners.MockitoJUnitRunner;
38 import org.onap.appc.client.lcm.api.LifeCycleManagerStateful;
39 import org.onap.appc.client.lcm.exceptions.AppcClientException;
40 import org.onap.appc.simulator.client.main.ClientRunner;
43 import java.nio.file.Path;
44 import java.nio.file.Paths;
47 @RunWith(MockitoJUnitRunner.class)
49 public class TestJsonRequestHandler {
51 JsonResponseHandler jsonResponseHandler=new JsonResponseHandler();
54 jsonResponseHandler= Mockito.mock(JsonResponseHandler.class);
59 public void testProceedFiles() throws AppcClientException,java.io.IOException{
60 String folder="src/test/resources/data";
61 List<File> sources = getJsonFiles(folder);
62 File source=sources.get(0);
63 File log = new File(folder + "/output.txt");
64 JsonRequestHandler requestHandler = new JsonRequestHandler();
65 Mockito.doNothing().when(jsonResponseHandler).onResponse(Matchers.anyBoolean());
66 requestHandler.proceedFile(source,log);
68 Assert.assertNotNull(log);
72 private static List<File> getJsonFiles(String folder) throws FileNotFoundException {
73 Path dir = Paths.get(folder);
74 FileFilter fileFilter = new WildcardFileFilter("*.json");
75 return new ArrayList<File>(Arrays.asList(dir.toFile().listFiles(fileFilter)));