move powermockito to mocktio appc-client
[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  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  * ============LICENSE_END=========================================================
23  */
24
25 package org.onap.appc.simulator.client.impl;
26
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;
41
42 import java.io.*;
43 import java.nio.file.Path;
44 import java.nio.file.Paths;
45 import java.util.*;
46
47 @RunWith(MockitoJUnitRunner.class)
48
49 public class TestJsonRequestHandler {
50
51     JsonResponseHandler jsonResponseHandler=new JsonResponseHandler();
52     @Before
53     public void init(){
54         jsonResponseHandler= Mockito.mock(JsonResponseHandler.class);
55     }
56
57
58     @Test
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);
67
68     Assert.assertNotNull(log);
69
70     }
71
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)));
76     }
77 }