@Override public Optional<EndpointRegistrationDto> findEndpointRegistrationByEndpointId(String endpointId) throws EndpointRegistrationServiceException { try { Validate.notBlank(endpointId, "Invalid endpoint ID provided!"); return this.endpointRegistrationDao.findByEndpointId(endpointId) .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 testRemoveByEndpointId() throws Exception { EndpointRegistrationDto endpointRegistrationDto = this.generateEndpointRegistration(APPLICATION_ID, ENDPOINT_ID, CREDENTIALS_ID, null, null); Assert.assertNotNull(endpointRegistrationDto); Assert.assertNotNull(endpointRegistrationDto.getId()); this.endpointRegistrationDao.removeByEndpointId(ENDPOINT_ID); Assert.assertNull(this.endpointRegistrationDao.findByEndpointId(ENDPOINT_ID).orElse(null)); } }
@Test public void testRemoveByEndpointId() throws Exception { EndpointRegistrationDto endpointRegistrationDto = this.generateEndpointRegistration(APPLICATION_ID, ENDPOINT_ID, CREDENTIALS_ID); Assert.assertNotNull(endpointRegistrationDto); Assert.assertNotNull(endpointRegistrationDto.getId()); this.endpointRegistrationDao.removeByEndpointId(ENDPOINT_ID); Assert.assertNull(this.endpointRegistrationDao.findByEndpointId(ENDPOINT_ID).orElse(null)); } }
@Test public void testFindByEndpointId() throws Exception { EndpointRegistrationDto endpointRegistrationDto = this.generateEndpointRegistration(APPLICATION_ID, ENDPOINT_ID, CREDENTIALS_ID); Assert.assertNotNull(endpointRegistrationDto); Assert.assertNotNull(endpointRegistrationDto.getId()); EndpointRegistration endpointRegistration = this.endpointRegistrationDao.findByEndpointId(ENDPOINT_ID).orElse(null); Assert.assertNotNull(endpointRegistration); Assert.assertEquals(endpointRegistrationDto, endpointRegistration.toDto()); }
@Test public void testFindByEndpointId() 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.findByEndpointId(ENDPOINT_ID).orElse(null); Assert.assertNotNull(endpointRegistration); Assert.assertEquals(endpointRegistrationDto, endpointRegistration.toDto()); }