Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix npe when applying modifications from uuids and null reporterId #540

Merged
merged 2 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,6 @@ public ResponseEntity<Optional<NetworkModificationResult>> applyModifications(@P
@Parameter(description = "the report uuid") @RequestParam(value = "reportUuid", required = false) UUID reportUuid,
@Parameter(description = "the reporter id") @RequestParam(value = "reporterId", required = false) String reporterId,
@RequestBody List<UUID> modificationsUuidList) {
return ResponseEntity.ok().body(networkModificationService.applyModificationsFromUuids(networkUuid, variantId, new ReportInfos(reportUuid, UUID.fromString(reporterId)), modificationsUuidList));
return ResponseEntity.ok().body(networkModificationService.applyModificationsFromUuids(networkUuid, variantId, new ReportInfos(reportUuid, reporterId != null ? UUID.fromString(reporterId) : null), modificationsUuidList));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1634,10 +1634,10 @@ public void testApplyModificationsFromUuids() throws Exception {
assertNotNull(sw);
assertFalse(sw.isOpen()); // switch is closed

// apply the modification on the network
// apply the modification on the network with a reporterId
mvcResult = mockMvc.perform(
put("/v1/networks/" + TEST_NETWORK_ID + "/apply"
+ "?variantId=" + NetworkCreation.VARIANT_ID + "&reporterId=" + UUID.randomUUID().toString())
+ "?variantId=" + NetworkCreation.VARIANT_ID + "&reporterId=" + UUID.randomUUID())
.content(objectWriter.writeValueAsString(modificationUuidList))
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()).andReturn();
Expand All @@ -1651,5 +1651,14 @@ public void testApplyModificationsFromUuids() throws Exception {
assertEquals(modificationUuidList, newModificationUuidList);

assertTrue(sw.isOpen()); // switch is opened

// apply the modification on the network without reporterId
mvcResult = mockMvc.perform(
put("/v1/networks/" + TEST_NETWORK_ID + "/apply"
+ "?variantId=" + NetworkCreation.VARIANT_ID)
.content(objectWriter.writeValueAsString(modificationUuidList))
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()).andReturn();
assertApplicationStatusOK(mvcResult);
}
}
Loading