Skip to content

Commit 72cdf4a

Browse files
committed
Add comment en LOGGER.debug
Change null to notExistsId in TUs Signed-off-by: sBouzols <[email protected]>
1 parent b8d031e commit 72cdf4a

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/main/java/org/gridsuite/geodata/server/GeoDataService.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,10 @@ private void prepareGeoDataForComputation(Network network, Map<String, Substatio
179179
if (geoDataForComputation.get(neighbourId) == null && !substationsToCalculate.contains(neighbourId)) {
180180
substationsToCalculate.add(neighbourId);
181181
Substation sub = network.getSubstation(neighbourId);
182-
if (sub != null) {
182+
if (sub != null) { // comes from a Request param string, could not exists in the network
183183
substations.add(sub);
184+
} else {
185+
LOGGER.debug("{} substation doesn't exist in the newtwork, will be ignored.", neighbourId);
184186
}
185187
}
186188
});
@@ -539,7 +541,16 @@ public List<LineGeoData> getLinesByIds(Network network, Set<String> linesIds) {
539541

540542
StopWatch stopWatch = StopWatch.createStarted();
541543

542-
List<Line> lines = linesIds.stream().map(network::getLine).filter(Objects::nonNull).collect(Collectors.toList());
544+
List<Line> lines = new ArrayList<>();
545+
546+
linesIds.forEach(id -> {
547+
Line line = network.getLine(id);
548+
if (line != null) { // comes from a Request param string, could not exists in the network
549+
lines.add(line);
550+
} else {
551+
LOGGER.debug("{} line doesn't exist in the newtwork, will be ignored.", id);
552+
}
553+
});
543554

544555
// read lines from DB
545556
Map<String, LineGeoData> linesGeoDataDb = lineRepository.findAllById(linesIds).stream().collect(Collectors.toMap(LineEntity::getId, this::toDto));

src/test/java/org/gridsuite/geodata/server/GeoDataControllerTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,13 @@ void test() throws Exception {
162162
.andExpect(content().contentTypeCompatibleWith(APPLICATION_JSON))
163163
.andExpect(jsonPath("$", hasSize(0)));
164164

165-
mvc.perform(get("/" + VERSION + "/substations?networkUuid=" + networkUuid + "&variantId=" + VARIANT_ID + "&substationId=null&substationId=P2")
165+
mvc.perform(get("/" + VERSION + "/substations?networkUuid=" + networkUuid + "&variantId=" + VARIANT_ID + "&substationId=notExistsId&substationId=P2")
166166
.contentType(APPLICATION_JSON))
167167
.andExpect(status().isOk())
168168
.andExpect(content().contentTypeCompatibleWith(APPLICATION_JSON))
169169
.andExpect(jsonPath("$", hasSize(0)));
170170

171-
mvc.perform(get("/" + VERSION + "/substations?networkUuid=" + networkUuid + "&variantId=" + VARIANT_ID + "&substationId=null")
171+
mvc.perform(get("/" + VERSION + "/substations?networkUuid=" + networkUuid + "&variantId=" + VARIANT_ID + "&substationId=notExistsId")
172172
.contentType(APPLICATION_JSON))
173173
.andExpect(status().isOk())
174174
.andExpect(content().contentTypeCompatibleWith(APPLICATION_JSON))
@@ -186,13 +186,13 @@ void test() throws Exception {
186186
.andExpect(content().contentTypeCompatibleWith(APPLICATION_JSON))
187187
.andExpect(jsonPath("$", hasSize(0)));
188188

189-
mvc.perform(get("/" + VERSION + "/lines?networkUuid=" + networkUuid + "&variantId=" + VARIANT_ID + "&lineId=NHV1_NHV2_2&lineId=null")
189+
mvc.perform(get("/" + VERSION + "/lines?networkUuid=" + networkUuid + "&variantId=" + VARIANT_ID + "&lineId=NHV1_NHV2_2&lineId=notExistsId")
190190
.contentType(APPLICATION_JSON))
191191
.andExpect(status().isOk())
192192
.andExpect(content().contentTypeCompatibleWith(APPLICATION_JSON))
193193
.andExpect(jsonPath("$", hasSize(0)));
194194

195-
mvc.perform(get("/" + VERSION + "/lines?networkUuid=" + networkUuid + "&variantId=" + VARIANT_ID + "&lineId=null")
195+
mvc.perform(get("/" + VERSION + "/lines?networkUuid=" + networkUuid + "&variantId=" + VARIANT_ID + "&lineId=notExistsId")
196196
.contentType(APPLICATION_JSON))
197197
.andExpect(status().isOk())
198198
.andExpect(content().contentTypeCompatibleWith(APPLICATION_JSON))

0 commit comments

Comments
 (0)