use of se.inera.intyg.webcert.web.integration.registry.dto.IntegreradEnhetEntry in project webcert by sklintyg.
the class IntegreradeEnheterRegistryImplTest method testAddIfSameVardgivareButDifferentUnitsAlreadyExists.
@Test
public void testAddIfSameVardgivareButDifferentUnitsAlreadyExists() {
final String enhetsId = "enhetsId";
final String vardgivarId = "vardgivarId";
IntegreradEnhetEntry entry = new IntegreradEnhetEntry(enhetsId, vardgivarId);
IntegreradEnhet integreradEnhet = new IntegreradEnhet();
integreradEnhet.setEnhetsId(enhetsId);
integreradEnhet.setSchemaVersion3(true);
integreradEnhet.setVardgivarId(vardgivarId);
when(integreradEnhetRepository.findOne(eq(enhetsId))).thenReturn(integreradEnhet);
registry.addIfSameVardgivareButDifferentUnits(enhetsId, entry, LuseEntryPoint.MODULE_ID);
ArgumentCaptor<IntegreradEnhet> enhetCaptor = ArgumentCaptor.forClass(IntegreradEnhet.class);
verify(integreradEnhetRepository, times(2)).save(enhetCaptor.capture());
assertNotNull(enhetCaptor.getValue().getSenasteKontrollDatum());
}
use of se.inera.intyg.webcert.web.integration.registry.dto.IntegreradEnhetEntry in project webcert by sklintyg.
the class IntegreradeEnheterRegistryImplTest method testPutIntegreradEnhetAlreadyExists.
@Test
public void testPutIntegreradEnhetAlreadyExists() {
final String enhetsId = "enhetsId";
IntegreradEnhetEntry entry = new IntegreradEnhetEntry(enhetsId, "vardgivareId");
IntegreradEnhet integreradEnhet = new IntegreradEnhet();
integreradEnhet.setSchemaVersion1(false);
integreradEnhet.setSchemaVersion3(true);
when(integreradEnhetRepository.findOne(enhetsId)).thenReturn(integreradEnhet);
when(integreradEnhetRepository.save(any(IntegreradEnhet.class))).thenReturn(new IntegreradEnhet());
registry.putIntegreradEnhet(entry, true, false);
ArgumentCaptor<IntegreradEnhet> enhetCaptor = ArgumentCaptor.forClass(IntegreradEnhet.class);
verify(integreradEnhetRepository, times(1)).save(enhetCaptor.capture());
assertTrue(enhetCaptor.getValue().isSchemaVersion1());
assertTrue(enhetCaptor.getValue().isSchemaVersion3());
}
use of se.inera.intyg.webcert.web.integration.registry.dto.IntegreradEnhetEntry in project webcert by sklintyg.
the class IntegreradeEnheterRegistryImplTest method testAddIfSameVardgivareButDifferentUnitsCopiesSchemaVersion.
@Test
public void testAddIfSameVardgivareButDifferentUnitsCopiesSchemaVersion() {
final String enhetsId = "enhetsId";
final String vardgivarId = "vardgivarId";
IntegreradEnhetEntry entry = new IntegreradEnhetEntry(enhetsId, vardgivarId);
IntegreradEnhet integreradEnhet = new IntegreradEnhet();
integreradEnhet.setEnhetsId("another enhetsId");
integreradEnhet.setSchemaVersion3(true);
integreradEnhet.setVardgivarId(vardgivarId);
// already exists
when(integreradEnhetRepository.findOne(eq(enhetsId))).thenReturn(integreradEnhet);
when(integreradEnhetRepository.save(any(IntegreradEnhet.class))).thenReturn(new IntegreradEnhet());
registry.addIfSameVardgivareButDifferentUnits(enhetsId, entry, LuseEntryPoint.MODULE_ID);
ArgumentCaptor<IntegreradEnhet> enhetCaptor = ArgumentCaptor.forClass(IntegreradEnhet.class);
verify(integreradEnhetRepository, times(3)).save(enhetCaptor.capture());
assertNotNull(enhetCaptor.getAllValues().get(0).getSenasteKontrollDatum());
assertTrue(enhetCaptor.getAllValues().get(1).isSchemaVersion3());
}
Aggregations