Revize 0f482858
Přidáno uživatelem Tomáš Šimandl před více než 6 roky(ů)
sources/src/main/java/cz/zcu/kiv/offscreen/graph/loader/GraphJSONDataLoader.java | ||
---|---|---|
9 | 9 |
import cz.zcu.kiv.offscreen.graph.Attribute; |
10 | 10 |
import cz.zcu.kiv.offscreen.graph.EdgeArchetypeInfo; |
11 | 11 |
import cz.zcu.kiv.offscreen.graph.GraphManager; |
12 |
import org.apache.commons.io.IOUtils; |
|
13 | 12 |
|
14 |
import java.io.File; |
|
15 |
import java.io.IOException; |
|
16 | 13 |
import java.math.BigDecimal; |
17 | 14 |
import java.text.ParsePosition; |
18 | 15 |
import java.text.SimpleDateFormat; |
... | ... | |
38 | 35 |
private HashMap<Integer, Integer> vertexArchetypes = new HashMap<>(); |
39 | 36 |
|
40 | 37 |
|
41 |
public GraphJSONDataLoader(File file) { |
|
42 |
try { |
|
43 |
loadedJSON = IOUtils.toString(getClass().getClassLoader().getResourceAsStream(file.getPath()), "UTF-8"); |
|
44 |
} catch (IOException e) { |
|
45 |
e.printStackTrace(); |
|
46 |
} |
|
47 |
} |
|
48 |
|
|
49 | 38 |
public GraphJSONDataLoader(String json){ |
50 | 39 |
loadedJSON = json; |
51 | 40 |
} |
sources/src/test/java/cz/zcu/kiv/imiger/tests/backend/GraphFilterTest.java | ||
---|---|---|
7 | 7 |
import cz.zcu.kiv.offscreen.graph.GraphManager; |
8 | 8 |
import cz.zcu.kiv.offscreen.graph.loader.GraphJSONDataLoader; |
9 | 9 |
import cz.zcu.kiv.offscreen.graph.loader.JSONConfigLoader; |
10 |
import org.apache.commons.io.IOUtils; |
|
10 | 11 |
import org.junit.jupiter.api.Assertions; |
11 | 12 |
import org.junit.jupiter.api.BeforeAll; |
12 | 13 |
import org.junit.jupiter.api.Test; |
13 | 14 |
|
14 | 15 |
import java.io.File; |
16 |
import java.io.IOException; |
|
15 | 17 |
import java.util.ArrayList; |
16 | 18 |
import java.util.List; |
17 | 19 |
|
... | ... | |
20 | 22 |
private static GraphManager graphManager; |
21 | 23 |
|
22 | 24 |
@BeforeAll |
23 |
static void initTest() { |
|
24 |
graphManager = new GraphJSONDataLoader(new File("data/test1.json")).loadData(); |
|
25 |
static void initTest() throws IOException { |
|
26 |
String loadedJSON = IOUtils.toString(GraphFilterTest.class.getClassLoader().getResourceAsStream("data/test1.json"), "UTF-8"); |
|
27 |
graphManager = new GraphJSONDataLoader(loadedJSON).loadData(); |
|
25 | 28 |
} |
26 | 29 |
|
27 | 30 |
@Test |
Také k dispozici: Unified diff
Move file loading to tests
- Loading diagram by file is used and will be used only in tests