1 package org.openecomp.appc.simulator.client.impl;
3 import org.apache.commons.io.filefilter.WildcardFileFilter;
4 import org.junit.Assert;
5 import org.junit.Ignore;
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;
15 public class TestJsonResponseHandler {
16 String folder="/data/output/error.json";
17 JsonResponseHandler responseHandler=new JsonResponseHandler();
20 public void testOnResponse() throws URISyntaxException, IOException{
21 responseHandler.onResponse(getNode());
22 List<File> files=getJsonFiles(folder);
23 Assert.assertNotNull(files);
27 private String readData(String inputFile) throws URISyntaxException, IOException {
28 File file = new File(this.getClass().getResource(inputFile).toURI());
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);
37 private String getNode() throws java.io.IOException{
38 String jsonSring="{\"status\": {\"code\": \"200\"}}";
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)));