Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -73,4 +73,12 @@ public ResponseEntity<MatchedRule> getNetworkMatches(@PathVariable("networkUuid"
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(networkService.getNetworkMatches(networkUuid, ruleToMatch));
}

@DeleteMapping(path = "/{networkUuid}")
@Operation(summary = "delete the network")
@ApiResponse(responseCode = "200", description = "Network deleted")
public ResponseEntity<String> deleteNetwork(@PathVariable("networkUuid") UUID networkUuid) {
networkService.deleteNetwork(networkUuid);
return ResponseEntity.ok().contentType(MediaType.TEXT_PLAIN).body(networkUuid.toString());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ public interface NetworkService {
Network getNetwork(UUID networkUuid);

MatchedRule getNetworkMatches(UUID networkUuid, RuleToMatch ruleToMatch);

String deleteNetwork(UUID networkUuid);
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ public NetworkValues getNetworkValuesFromExistingNetwork(UUID networkUuid) {
return new NetworkValues(networkUuid, equipmentValuesList);
}

@Override
public String deleteNetwork(UUID networkUuid) {
networkRepository.deleteById(networkUuid);
networkStoreService.deleteNetwork(networkUuid);
return networkUuid.toString();
}

private void setPropertyMap(HashMap<String, Set<String>> propertyMap, String value, String propertyName) {
if (propertyMap.containsKey(propertyName)) {
Set<String> propertyValues = propertyMap.get(propertyName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ public void fileTest() throws Exception {
NetworkEntity actualEntity = savedNetworks.get(0);
assertTrue(expectedEntity.getNetworkId().equals(actualEntity.getNetworkId()) && expectedEntity.getNetworkName().equals(actualEntity.getNetworkName()));

mvc.perform(MockMvcRequestBuilders.delete("/network/" + networkUUID)).andExpect(status().isOk());
savedNetworks = networkRepository.findAll();
assertEquals(0, savedNetworks.size());

}

private String network(UUID id, String name) {
Expand Down