summaryrefslogtreecommitdiffstats
path: root/appc-client/client-simulator/src/test/java/org/openecomp/appc/simulator/client/impl/TestJsonResponseHandler.java
blob: b477b8a61b8603507be3ed3fa97d5187203282ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package org.openecomp.appc.simulator.client.impl;

import org.apache.commons.io.filefilter.WildcardFileFilter;
import org.junit.Assert;
import org.junit.Ignore;
import java.io.*;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;


public class TestJsonResponseHandler {
    String folder="/data/output/error.json";
    JsonResponseHandler responseHandler=new JsonResponseHandler();

    @Ignore
    public void testOnResponse() throws URISyntaxException, IOException{
        responseHandler.onResponse(getNode());
        List<File> files=getJsonFiles(folder);
        Assert.assertNotNull(files);

    }

    private String readData(String inputFile) throws URISyntaxException, IOException {
        File file = new File(this.getClass().getResource(inputFile).toURI());

        byte[] bFile = new byte[(int) file.length()];
        FileInputStream fileInputStream = new FileInputStream(file);
        fileInputStream.read(bFile);
        fileInputStream.close();
        return new String(bFile);
    }

    private String getNode() throws java.io.IOException{
        String jsonSring="{\"status\": {\"code\": \"200\"}}";
        return  jsonSring;
}
    public  List<File> getJsonFiles(String folder) throws FileNotFoundException {
        Path dir = Paths.get(folder);
        FileFilter fileFilter = new WildcardFileFilter("*.error");
        return new ArrayList<File>(Arrays.asList(dir.toFile().listFiles(fileFilter)));
    }
}