b477b8a61b8603507be3ed3fa97d5187203282ad
[appc.git] / appc-client / client-simulator / src / test / java / org / openecomp / appc / simulator / client / impl / TestJsonResponseHandler.java
1 package org.openecomp.appc.simulator.client.impl;
2
3 import org.apache.commons.io.filefilter.WildcardFileFilter;
4 import org.junit.Assert;
5 import org.junit.Ignore;
6 import java.io.*;
7 import java.net.URISyntaxException;
8 import java.nio.file.Path;
9 import java.nio.file.Paths;
10 import java.util.ArrayList;
11 import java.util.Arrays;
12 import java.util.List;
13
14
15 public class TestJsonResponseHandler {
16     String folder="/data/output/error.json";
17     JsonResponseHandler responseHandler=new JsonResponseHandler();
18
19     @Ignore
20     public void testOnResponse() throws URISyntaxException, IOException{
21         responseHandler.onResponse(getNode());
22         List<File> files=getJsonFiles(folder);
23         Assert.assertNotNull(files);
24
25     }
26
27     private String readData(String inputFile) throws URISyntaxException, IOException {
28         File file = new File(this.getClass().getResource(inputFile).toURI());
29
30         byte[] bFile = new byte[(int) file.length()];
31         FileInputStream fileInputStream = new FileInputStream(file);
32         fileInputStream.read(bFile);
33         fileInputStream.close();
34         return new String(bFile);
35     }
36
37     private String getNode() throws java.io.IOException{
38         String jsonSring="{\"status\": {\"code\": \"200\"}}";
39         return  jsonSring;
40 }
41     public  List<File> getJsonFiles(String folder) throws FileNotFoundException {
42         Path dir = Paths.get(folder);
43         FileFilter fileFilter = new WildcardFileFilter("*.error");
44         return new ArrayList<File>(Arrays.asList(dir.toFile().listFiles(fileFilter)));
45     }
46 }