Skip to content

Commit fbe9e40

Browse files
authored
Add open data resources (#69)
Signed-off-by: sBouzols <[email protected]>
1 parent 1b93ed5 commit fbe9e40

File tree

3 files changed

+474
-0
lines changed

3 files changed

+474
-0
lines changed

geo-data-server/src/test/java/org/gridsuite/geodata/server/GeoDataControllerTest.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
import org.springframework.test.context.junit4.SpringRunner;
2424
import org.springframework.test.web.servlet.MockMvc;
2525

26+
import com.google.common.io.ByteStreams;
27+
import java.io.IOException;
28+
import java.io.UncheckedIOException;
29+
import java.nio.charset.StandardCharsets;
30+
import java.util.Objects;
31+
2632
import java.util.ArrayList;
2733
import java.util.Collections;
2834
import java.util.UUID;
@@ -60,6 +66,17 @@ public class GeoDataControllerTest {
6066
@MockBean
6167
private LineRepository lineRepository;
6268

69+
private static final String OPEN_SUBSTATIONS = "/open_substations.json";
70+
private static final String OPEN_LINES = "/open_lines.json";
71+
72+
public String toString(String resourceName) {
73+
try {
74+
return new String(ByteStreams.toByteArray(Objects.requireNonNull(getClass().getResourceAsStream(resourceName))), StandardCharsets.UTF_8);
75+
} catch (IOException e) {
76+
throw new UncheckedIOException(e);
77+
}
78+
}
79+
6380
@Test
6481
public void test() throws Exception {
6582
UUID networkUuid = UUID.fromString("7928181c-7977-4592-ba19-88027e4254e4");
@@ -101,5 +118,15 @@ public void test() throws Exception {
101118
.coordinates(new ArrayList<>())
102119
.build()))))
103120
.andExpect(status().isOk());
121+
122+
mvc.perform(post("/" + VERSION + "/substations")
123+
.contentType(APPLICATION_JSON)
124+
.content(toString(OPEN_SUBSTATIONS)))
125+
.andExpect(status().isOk());
126+
127+
mvc.perform(post("/" + VERSION + "/lines")
128+
.contentType(APPLICATION_JSON)
129+
.content(toString(OPEN_LINES)))
130+
.andExpect(status().isOk());
104131
}
105132
}
Lines changed: 333 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,333 @@
1+
[
2+
{
3+
"id": "_ffbabc27-1ccd-4fdc-b037-e341706c8d29",
4+
"country1": "BE",
5+
"country2": "BE",
6+
"substationStart": "_37e14a0f-5e34-4647-a062-8bfd9305fa9d",
7+
"substationEnd": "_87f7002b-056f-4a6a-a872-1744eea757e3",
8+
"coordinates": [
9+
{
10+
"lat": 50.9169,
11+
"lon": 4.34509
12+
},
13+
{
14+
"lat": 51.0448,
15+
"lon": 4.29565
16+
},
17+
{
18+
"lat": 51.157,
19+
"lon": 4.38354
20+
}
21+
]
22+
},
23+
{
24+
"id": "_b58bf21a-096a-4dae-9a01-3f03b60c24c7",
25+
"country1": "BE",
26+
"country2": "BE",
27+
"substationStart": "_37e14a0f-5e34-4647-a062-8bfd9305fa9d",
28+
"substationEnd": "_87f7002b-056f-4a6a-a872-1744eea757e3",
29+
"coordinates": [
30+
{
31+
"lat": 50.9169,
32+
"lon": 4.34509
33+
},
34+
{
35+
"lat": 51.0448,
36+
"lon": 4.29565
37+
},
38+
{
39+
"lat": 51.157,
40+
"lon": 4.38354
41+
}
42+
]
43+
},
44+
{
45+
"id": "L10-11-1",
46+
"country1": "DE",
47+
"country2": "DE",
48+
"substationStart": "S9",
49+
"substationEnd": "S10",
50+
"coordinates": [
51+
{
52+
"lat": 49.49199,
53+
"lon": 10.20535
54+
},
55+
{
56+
"lat": 49.19199,
57+
"lon": 11.90535
58+
}
59+
]
60+
},
61+
{
62+
"id": "L13-14-1",
63+
"country1": "DE",
64+
"country2": "DE",
65+
"substationStart": "S4",
66+
"substationEnd": "S5",
67+
"coordinates": [
68+
{
69+
"lat": 52.38668,
70+
"lon": 9.74317
71+
},
72+
{
73+
"lat": 50.36339,
74+
"lon": 8.19889
75+
}
76+
]
77+
},
78+
{
79+
"id": "L3-4-1",
80+
"country1": "BE",
81+
"country2": "FR",
82+
"substationStart": "S7",
83+
"substationEnd": "S1",
84+
"coordinates": [
85+
{
86+
"lat": 50.84716,
87+
"lon": 4.3508
88+
},
89+
{
90+
"lat": 49.17863,
91+
"lon": 6.16156
92+
}
93+
]
94+
},
95+
{
96+
"id": "L12-13-1",
97+
"country1": "PL",
98+
"country2": "DE",
99+
"substationStart": "S11",
100+
"substationEnd": "S4",
101+
"coordinates": [
102+
{
103+
"lat": 52.10062,
104+
"lon": 21.2075
105+
},
106+
{
107+
"lat": 52.38668,
108+
"lon": 9.74317
109+
}
110+
]
111+
},
112+
{
113+
"id": "L9-14-1",
114+
"country1": "FR",
115+
"country2": "DE",
116+
"substationStart": "S1",
117+
"substationEnd": "S5",
118+
"coordinates": [
119+
{
120+
"lat": 49.17863,
121+
"lon": 6.16156
122+
},
123+
{
124+
"lat": 50.36339,
125+
"lon": 8.19889
126+
}
127+
]
128+
},
129+
{
130+
"id": "L1-5-1",
131+
"country1": "FR",
132+
"country2": "AT",
133+
"substationStart": "S6",
134+
"substationEnd": "S2",
135+
"coordinates": [
136+
{
137+
"lat": 45.34069,
138+
"lon": 1.65383
139+
},
140+
{
141+
"lat": 47.43046,
142+
"lon": 14.69182
143+
}
144+
]
145+
},
146+
{
147+
"id": "L9-10-1",
148+
"country1": "FR",
149+
"country2": "DE",
150+
"substationStart": "S1",
151+
"substationEnd": "S9",
152+
"coordinates": [
153+
{
154+
"lat": 49.17863,
155+
"lon": 6.16156
156+
},
157+
{
158+
"lat": 49.49199,
159+
"lon": 10.20535
160+
}
161+
]
162+
},
163+
{
164+
"id": "L2-5-1",
165+
"country1": "FR",
166+
"country2": "AT",
167+
"substationStart": "S8",
168+
"substationEnd": "S2",
169+
"coordinates": [
170+
{
171+
"lat": 48.856,
172+
"lon": 2.344
173+
},
174+
{
175+
"lat": 47.43046,
176+
"lon": 14.69182
177+
}
178+
]
179+
},
180+
{
181+
"id": "L1-2-1",
182+
"country1": "FR",
183+
"country2": "FR",
184+
"substationStart": "S6",
185+
"substationEnd": "S8",
186+
"coordinates": [
187+
{
188+
"lat": 45.34069,
189+
"lon": 1.65383
190+
},
191+
{
192+
"lat": 48.856,
193+
"lon": 2.344
194+
}
195+
]
196+
},
197+
{
198+
"id": "L2-3-1",
199+
"country1": "FR",
200+
"country2": "BE",
201+
"substationStart": "S8",
202+
"substationEnd": "S7",
203+
"coordinates": [
204+
{
205+
"lat": 48.856,
206+
"lon": 2.344
207+
},
208+
{
209+
"lat": 50.84716,
210+
"lon": 4.3508
211+
}
212+
]
213+
},
214+
{
215+
"id": "L4-5-1",
216+
"country1": "FR",
217+
"country2": "AT",
218+
"substationStart": "S1",
219+
"substationEnd": "S2",
220+
"coordinates": [
221+
{
222+
"lat": 49.17863,
223+
"lon": 6.16156
224+
},
225+
{
226+
"lat": 47.43046,
227+
"lon": 14.69182
228+
}
229+
]
230+
},
231+
{
232+
"id": "L7-8-1",
233+
"country1": "FR",
234+
"country2": "NL",
235+
"substationStart": "S1",
236+
"substationEnd": "S3",
237+
"coordinates": [
238+
{
239+
"lat": 49.17863,
240+
"lon": 6.16156
241+
},
242+
{
243+
"lat": 53.19624,
244+
"lon": 6.60964
245+
}
246+
]
247+
},
248+
{
249+
"id": "L2-4-1",
250+
"country1": "FR",
251+
"country2": "FR",
252+
"substationStart": "S8",
253+
"substationEnd": "S1",
254+
"coordinates": [
255+
{
256+
"lat": 48.856,
257+
"lon": 2.344
258+
},
259+
{
260+
"lat": 49.17863,
261+
"lon": 6.16156
262+
}
263+
]
264+
},
265+
{
266+
"id": "L6-11-1",
267+
"country1": "AT",
268+
"country2": "DE",
269+
"substationStart": "S2",
270+
"substationEnd": "S10",
271+
"coordinates": [
272+
{
273+
"lat": 47.43046,
274+
"lon": 14.69182
275+
},
276+
{
277+
"lat": 49.19199,
278+
"lon": 11.90535
279+
}
280+
]
281+
},
282+
{
283+
"id": "L7-9-1",
284+
"country1": "FR",
285+
"country2": "FR",
286+
"substationStart": "S1",
287+
"substationEnd": "S1",
288+
"coordinates": [
289+
{
290+
"lat": 49.17863,
291+
"lon": 6.16156
292+
},
293+
{
294+
"lat": 49.17863,
295+
"lon": 6.16156
296+
}
297+
]
298+
},
299+
{
300+
"id": "L6-12-1",
301+
"country1": "AT",
302+
"country2": "PL",
303+
"substationStart": "S2",
304+
"substationEnd": "S11",
305+
"coordinates": [
306+
{
307+
"lat": 47.43046,
308+
"lon": 14.69182
309+
},
310+
{
311+
"lat": 52.10062,
312+
"lon": 21.2075
313+
}
314+
]
315+
},
316+
{
317+
"id": "L6-13-1",
318+
"country1": "AT",
319+
"country2": "DE",
320+
"substationStart": "S2",
321+
"substationEnd": "S4",
322+
"coordinates": [
323+
{
324+
"lat": 47.43046,
325+
"lon": 14.69182
326+
},
327+
{
328+
"lat": 52.38668,
329+
"lon": 9.74317
330+
}
331+
]
332+
}
333+
]

0 commit comments

Comments
 (0)