@Override public Optional<EndpointRegistrationDto> findEndpointRegistrationByCredentialsId( String credentialsId) throws EndpointRegistrationServiceException { try { Validate.notBlank(credentialsId, "Invalid credentials ID provided!"); return this.endpointRegistrationDao.findByCredentialsId(credentialsId).map( EndpointRegistration::toDto); } catch (Exception cause) { LOG.error("An unexpected exception occured while searching for endpoint registration!", cause); throw new EndpointRegistrationServiceException(cause); } }
@Test public void testFindByCredentialsId() throws Exception { EndpointRegistrationDto endpointRegistrationDto = this.generateEndpointRegistration(APPLICATION_ID, ENDPOINT_ID, CREDENTIALS_ID, null, null); Assert.assertNotNull(endpointRegistrationDto); Assert.assertNotNull(endpointRegistrationDto.getId()); EndpointRegistration endpointRegistration = this.endpointRegistrationDao.findByCredentialsId(CREDENTIALS_ID).orElse(null); Assert.assertNotNull(endpointRegistration); Assert.assertEquals(endpointRegistrationDto, endpointRegistration.toDto()); }
@Test public void testFindByCredentialsId() throws Exception { EndpointRegistrationDto endpointRegistrationDto = this.generateEndpointRegistration(APPLICATION_ID, ENDPOINT_ID, CREDENTIALS_ID); Assert.assertNotNull(endpointRegistrationDto); Assert.assertNotNull(endpointRegistrationDto.getId()); EndpointRegistration endpointRegistration = this.endpointRegistrationDao.findByCredentialsId(CREDENTIALS_ID).orElse(null); Assert.assertNotNull(endpointRegistration); Assert.assertEquals(endpointRegistrationDto, endpointRegistration.toDto()); }