ConsentDtoFactoryImpl implements ConsentDtoFactory { @Override public ConsentDto createConsentDto(long consentId) { Consent consent = consentRepository.findOne(consentId); ConsentDto consentDto = consentExportMapper.map(consent); return consentDto; } ConsentDtoFactoryImpl(ConsentRepository consentRepository,
			ModelMapper modelMapper, ConsentExportMapper consentExportMapper); @Override ConsentDto createConsentDto(long consentId); @Override ConsentDto createConsentDto(Object obj);  }
@Test public void testCreateConsentDto_Repository_Is_Called() { long consentId = 1; Consent consent = mock(Consent.class); when(consentRepository.findOne(anyLong())).thenReturn(consent); ConsentDto consentDto = mock(ConsentDto.class); when(consentExportMapper.map(consent)).thenReturn(consentDto); sut.createConsentDto(consentId); verify(consentRepository).findOne(consentId); }
@Test public void testCreateConsentDto_Returns_Successfully() { long consentId = 1; Consent consent = mock(Consent.class); when(consentRepository.findOne(anyLong())).thenReturn(consent); ConsentDto consentDtoMock = mock(ConsentDto.class); when(consentExportMapper.map(consent)).thenReturn(consentDtoMock); ConsentDto consentDto = sut.createConsentDto(consentId); assertEquals(consentDtoMock, consentDto); }
@Test public void testCreateConsentDto_ObjectReturns_Successfully() { Consent consent = mock(Consent.class); ConsentDto consentDtoMock = mock(ConsentDto.class); when(consentExportMapper.map(consent)).thenReturn(consentDtoMock); ConsentDto consentDto = sut.createConsentDto(consent); assertEquals(consentDtoMock, consentDto); }
@Test public void testCreateConsentDto_ConsentReturns_Successfully() { ConsentDto consentDtoMock = mock(ConsentDto.class); Consent consent = new Consent(); when(consentExportMapper.map(consent)).thenReturn(consentDtoMock); ConsentDto consentDto = sut.createConsentDto(consent); assertEquals(consentDtoMock, consentDto); }
@Test public void testCreateConsentDto_Loong_Returns_Successfully() { Long consentId = new Long(1); Consent consent = mock(Consent.class); when(consentRepository.findOne(anyLong())).thenReturn(consent); ConsentDto consentDtoMock = mock(ConsentDto.class); when(consentExportMapper.map(consent)).thenReturn(consentDtoMock); ConsentDto consentDto = sut.createConsentDto(consentId); assertEquals(consentDtoMock, consentDto); }
@Test public void testCreateConsentDto_Null_Returns_Successfully() { Long consentId = null; ConsentDto consentDto = sut.createConsentDto(consentId); assertNull(consentDto); }