### Question:
EndpointsApiController implements EndpointsApi { @Override @PreAuthorize("hasAuthority('EDIT_OPENAPI3_ENDPOINT')") @AuditEventMethod(event = EDIT_REST_ENDPOINT) public ResponseEntity<Endpoint> updateEndpoint(String id, EndpointUpdate endpointUpdate) { Long endpointId = parseLongIdOrThrowNotFound(id); Endpoint ep; try { String method = endpointUpdate.getMethod() == null ? null : endpointUpdate.getMethod().toString(); ep = endpointConverter.convert(endpointService.updateEndpoint(endpointId, method, endpointUpdate.getPath())); } catch (EndpointNotFoundException e) { throw new ResourceNotFoundException(NOT_FOUND_ERROR_MSG + " " + id); } catch (EndpointService.IllegalGeneratedEndpointUpdateException e) { throw new BadRequestException("Updating is not allowed for generated endpoint " + id); } catch (EndpointAlreadyExistsException e) { throw new ConflictException(e); } catch (ClientNotFoundException e) { throw new ConflictException("Client not found for the given endpoint with id: " + id); } return new ResponseEntity<>(ep, HttpStatus.OK); } @Autowired  EndpointsApiController(
            EndpointService endpointService,
            EndpointConverter endpointConverter,
            AccessRightService accessRightService,
            ServiceClientConverter serviceClientConverter,
            ServiceClientHelper serviceClientHelper,
            ServiceClientService serviceClientService); @Override @PreAuthorize("hasAuthority('VIEW_ENDPOINT')") ResponseEntity<Endpoint> getEndpoint(String id); @Override @PreAuthorize("hasAuthority('DELETE_ENDPOINT')") @AuditEventMethod(event = DELETE_REST_ENDPOINT) ResponseEntity<Void> deleteEndpoint(String id); @Override @PreAuthorize("hasAuthority('EDIT_OPENAPI3_ENDPOINT')") @AuditEventMethod(event = EDIT_REST_ENDPOINT) ResponseEntity<Endpoint> updateEndpoint(String id, EndpointUpdate endpointUpdate); @Override @PreAuthorize("hasAuthority('VIEW_ENDPOINT_ACL')") ResponseEntity<List<ServiceClient>> getEndpointServiceClients(String id); @Override @PreAuthorize("hasAuthority('EDIT_ENDPOINT_ACL')") ResponseEntity<List<ServiceClient>> addEndpointServiceClients(String id, ServiceClients serviceClients); @Override @PreAuthorize("hasAuthority('EDIT_ENDPOINT_ACL')") ResponseEntity<Void> deleteEndpointServiceClients(String id, ServiceClients serviceClients);  }### Answer:
@Test(expected = BadRequestException.class) @WithMockUser(authorities = { "EDIT_OPENAPI3_ENDPOINT" }) public void updateGeneratedEndpoint() { EndpointUpdate pathAndMethod = new EndpointUpdate(); pathAndMethod.setMethod(EndpointUpdate.MethodEnum.STAR); pathAndMethod.setPath("/test"); endpointsApiController.updateEndpoint("10", pathAndMethod); }
@Test(expected = IllegalArgumentException.class) @WithMockUser(authorities = { "EDIT_OPENAPI3_ENDPOINT" }) public void updateEndpointWithEmptyPathString() { EndpointUpdate pathAndMethod = new EndpointUpdate(); pathAndMethod.setPath(""); endpointsApiController.updateEndpoint("12", pathAndMethod); }
@Test(expected = IllegalArgumentException.class) @WithMockUser(authorities = { "EDIT_OPENAPI3_ENDPOINT" }) public void updateEndpointWithEmptyPathAndMethod() { EndpointUpdate pathAndMethod = new EndpointUpdate(); endpointsApiController.updateEndpoint("12", pathAndMethod); }
@Test @WithMockUser(authorities = { "EDIT_OPENAPI3_ENDPOINT" }) public void updateEndpoint() { EndpointUpdate pathAndMethod = new EndpointUpdate(); pathAndMethod.setMethod(EndpointUpdate.MethodEnum.STAR); pathAndMethod.setPath("/test"); endpointsApiController.updateEndpoint("12", pathAndMethod); ClientType client = clientService.getLocalClient(getClientId("FI", "GOV", "M2", "SS6")); EndpointType endpointType = client.getEndpoint().stream().filter(ep -> ep.getId().equals(12L)) .findFirst().get(); assertTrue(endpointType.getMethod().equals("*")); assertTrue(endpointType.getPath().equals("/test")); }