@Test public void getResourceName_ShouldReturnProjects_WhenUrlIsAProjectUrl() { when(request.getDescription(false)) .thenReturn("uri=/api/projects/some-project"); final String resourceName = cut.getResourceName(request); assertThat(resourceName).isEqualTo("projects"); }
String getResourceName(WebRequest request) { String description = request.getDescription(false); String[] uriParts = description.split("/"); String resourceName; if (uriParts.length >= 5) { resourceName = uriParts[4]; } else if (uriParts.length >= 3) { resourceName = uriParts[2]; } else { log.error("No resource in {}", description); resourceName = "unknown"; } return resourceName; }
ResponseDtoValidator extends ResponseEntityExceptionHandler { String getResourceName(WebRequest request) { String description = request.getDescription(false); String[] uriParts = description.split("/"); String resourceName; if (uriParts.length >= 5) { resourceName = uriParts[4]; } else if (uriParts.length >= 3) { resourceName = uriParts[2]; } else { log.error("No resource in {}", description); resourceName = "unknown"; } return resourceName; } }
ResponseDtoValidator extends ResponseEntityExceptionHandler { String getResourceName(WebRequest request) { String description = request.getDescription(false); String[] uriParts = description.split("/"); String resourceName; if (uriParts.length >= 5) { resourceName = uriParts[4]; } else if (uriParts.length >= 3) { resourceName = uriParts[2]; } else { log.error("No resource in {}", description); resourceName = "unknown"; } return resourceName; }  }
ResponseDtoValidator extends ResponseEntityExceptionHandler { String getResourceName(WebRequest request) { String description = request.getDescription(false); String[] uriParts = description.split("/"); String resourceName; if (uriParts.length >= 5) { resourceName = uriParts[4]; } else if (uriParts.length >= 3) { resourceName = uriParts[2]; } else { log.error("No resource in {}", description); resourceName = "unknown"; } return resourceName; }   }
ResponseDtoValidator extends ResponseEntityExceptionHandler { String getResourceName(WebRequest request) { String description = request.getDescription(false); String[] uriParts = description.split("/"); String resourceName; if (uriParts.length >= 5) { resourceName = uriParts[4]; } else if (uriParts.length >= 3) { resourceName = uriParts[2]; } else { log.error("No resource in {}", description); resourceName = "unknown"; } return resourceName; }    }