Skip to content

Commit

Permalink
Add comment en LOGGER.debug
Browse files Browse the repository at this point in the history
Change null to notExistsId in TUs

Signed-off-by: sBouzols <[email protected]>
  • Loading branch information
sBouzols committed Nov 26, 2024
1 parent b8d031e commit 72cdf4a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
15 changes: 13 additions & 2 deletions src/main/java/org/gridsuite/geodata/server/GeoDataService.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,10 @@ private void prepareGeoDataForComputation(Network network, Map<String, Substatio
if (geoDataForComputation.get(neighbourId) == null && !substationsToCalculate.contains(neighbourId)) {
substationsToCalculate.add(neighbourId);
Substation sub = network.getSubstation(neighbourId);
if (sub != null) {
if (sub != null) { // comes from a Request param string, could not exists in the network
substations.add(sub);
} else {
LOGGER.debug("{} substation doesn't exist in the newtwork, will be ignored.", neighbourId);
}
}
});
Expand Down Expand Up @@ -539,7 +541,16 @@ public List<LineGeoData> getLinesByIds(Network network, Set<String> linesIds) {

StopWatch stopWatch = StopWatch.createStarted();

List<Line> lines = linesIds.stream().map(network::getLine).filter(Objects::nonNull).collect(Collectors.toList());
List<Line> lines = new ArrayList<>();

linesIds.forEach(id -> {
Line line = network.getLine(id);
if (line != null) { // comes from a Request param string, could not exists in the network
lines.add(line);
} else {
LOGGER.debug("{} line doesn't exist in the newtwork, will be ignored.", id);
}
});

// read lines from DB
Map<String, LineGeoData> linesGeoDataDb = lineRepository.findAllById(linesIds).stream().collect(Collectors.toMap(LineEntity::getId, this::toDto));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@ void test() throws Exception {
.andExpect(content().contentTypeCompatibleWith(APPLICATION_JSON))
.andExpect(jsonPath("$", hasSize(0)));

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

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

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

mvc.perform(get("/" + VERSION + "/lines?networkUuid=" + networkUuid + "&variantId=" + VARIANT_ID + "&lineId=null")
mvc.perform(get("/" + VERSION + "/lines?networkUuid=" + networkUuid + "&variantId=" + VARIANT_ID + "&lineId=notExistsId")
.contentType(APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(APPLICATION_JSON))
Expand Down

0 comments on commit 72cdf4a

Please sign in to comment.