Mercurial > lada > lada-server
comparison src/test/java/de/intevation/lada/test/land/ProbeTest.java @ 832:59c51da59b30
Refactored test environment.
Land tests are using arquillian persistence extension (built on DBUnit).
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Fri, 18 Dec 2015 18:01:00 +0100 |
parents | |
children | cb1cfc8c81ed |
comparison
equal
deleted
inserted
replaced
831:3d76d476894f | 832:59c51da59b30 |
---|---|
1 package de.intevation.lada.test.land; | |
2 | |
3 import java.net.URL; | |
4 import java.util.Arrays; | |
5 import java.util.List; | |
6 | |
7 import javax.json.JsonObject; | |
8 import javax.json.JsonObjectBuilder; | |
9 import javax.json.JsonValue; | |
10 | |
11 import org.junit.Assert; | |
12 | |
13 import de.intevation.lada.Protocol; | |
14 | |
15 public class ProbeTest extends ServiceTest { | |
16 | |
17 private JsonObject expectedById; | |
18 private JsonObject create; | |
19 | |
20 /** | |
21 * @return The test protocol | |
22 */ | |
23 public List<Protocol> getProtocol() { | |
24 return protocol; | |
25 } | |
26 | |
27 @Override | |
28 public void init( | |
29 URL baseUrl, | |
30 List<Protocol> protocol | |
31 ) { | |
32 super.init(baseUrl, protocol); | |
33 // Attributes with timestamps | |
34 timestampAttributes = Arrays.asList(new String[]{ | |
35 "letzteAenderung", | |
36 "probeentnahmeBeginn", | |
37 "solldatumBeginn", | |
38 "solldatumEnde", | |
39 "treeModified" | |
40 }); | |
41 | |
42 // Prepare expected probe object | |
43 JsonObject content = readJsonResource("/datasets/dbUnit_probe.json"); | |
44 JsonObject probe = content.getJsonArray("land.probe").getJsonObject(0); | |
45 JsonObjectBuilder builder = convertObject(probe); | |
46 JsonObject trans = | |
47 content.getJsonArray("land.probe_translation").getJsonObject(0); | |
48 builder.add("probeIdAlt", trans.get("probe_id_alt")); | |
49 builder.add("mittelungsdauer", JsonValue.NULL); | |
50 builder.add("probeentnahmeEnde", JsonValue.NULL); | |
51 builder.add("erzeugerId", JsonValue.NULL); | |
52 builder.add("mplId", JsonValue.NULL); | |
53 builder.add("readonly", JsonValue.FALSE); | |
54 builder.add("owner", JsonValue.TRUE); | |
55 expectedById = builder.build(); | |
56 Assert.assertNotNull(expectedById); | |
57 | |
58 // Load probe object to test POST request | |
59 create = readJsonResource("/datasets/probe.json"); | |
60 Assert.assertNotNull(create); | |
61 } | |
62 | |
63 public final void execute() { | |
64 getAll("probe", "rest/probe"); | |
65 getById("probe", "rest/probe/1000", expectedById); | |
66 filter("probe", "rest/probe?qid=2&mst_id=11010&umw_id=N24"); | |
67 JsonObject created = create("probe", "rest/probe", create); | |
68 update("probe", "rest/probe/1000", "hauptprobenNr", "120510002", "130510002"); | |
69 delete("probe", "rest/probe/" + created.getJsonObject("data").get("id")); | |
70 } | |
71 } |