Changed to unmaintained
[appc.git] / appc-client / client-simulator / src / test / java / org / onap / appc / simulator / client / impl / TestJsonRequestHandler.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
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
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
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.
20  * 
21  * ============LICENSE_END=========================================================
22  */
23
24 package org.onap.appc.simulator.client.impl;
25
26 import com.fasterxml.jackson.databind.JsonNode;
27 import com.fasterxml.jackson.databind.ObjectMapper;
28 import org.apache.commons.io.filefilter.WildcardFileFilter;
29 import org.junit.Assert;
30 import org.junit.Before;
31 import org.junit.Ignore;
32 import org.junit.Test;
33 import org.junit.runner.RunWith;
34 import org.mockito.Matchers;
35 import org.mockito.Mockito;
36 import org.mockito.runners.MockitoJUnitRunner;
37 import org.onap.appc.client.lcm.api.LifeCycleManagerStateful;
38 import org.onap.appc.client.lcm.exceptions.AppcClientException;
39 import org.onap.appc.simulator.client.main.ClientRunner;
40
41 import java.io.*;
42 import java.nio.file.Path;
43 import java.nio.file.Paths;
44 import java.util.*;
45
46 @RunWith(MockitoJUnitRunner.class)
47
48 public class TestJsonRequestHandler {
49
50     JsonResponseHandler jsonResponseHandler=new JsonResponseHandler();
51     @Before
52     public void init(){
53         jsonResponseHandler= Mockito.mock(JsonResponseHandler.class);
54     }
55
56
57     @Test
58     public void testProceedFiles() throws AppcClientException,java.io.IOException{
59     String folder="src/test/resources/data";
60     List<File> sources = getJsonFiles(folder);
61     File source=sources.get(0);
62     File log = new File(folder + "/output.txt");
63     JsonRequestHandler requestHandler = new JsonRequestHandler();
64     Mockito.doNothing().when(jsonResponseHandler).onResponse(Matchers.anyBoolean());
65     requestHandler.proceedFile(source,log);
66
67     Assert.assertNotNull(log);
68
69     }
70
71     private static List<File> getJsonFiles(String folder) throws FileNotFoundException {
72         Path dir = Paths.get(folder);
73         FileFilter fileFilter = new WildcardFileFilter("*.json");
74         return new ArrayList<File>(Arrays.asList(dir.toFile().listFiles(fileFilter)));
75     }
76 }