Search in sources :

Example 6 with IntegreradEnhetEntry

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());
}
Also used : IntegreradEnhetEntry(se.inera.intyg.webcert.web.integration.registry.dto.IntegreradEnhetEntry) IntegreradEnhet(se.inera.intyg.webcert.persistence.integreradenhet.model.IntegreradEnhet) Test(org.junit.Test)

Example 7 with IntegreradEnhetEntry

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());
}
Also used : IntegreradEnhetEntry(se.inera.intyg.webcert.web.integration.registry.dto.IntegreradEnhetEntry) IntegreradEnhet(se.inera.intyg.webcert.persistence.integreradenhet.model.IntegreradEnhet) Test(org.junit.Test)

Example 8 with IntegreradEnhetEntry

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());
}
Also used : IntegreradEnhetEntry(se.inera.intyg.webcert.web.integration.registry.dto.IntegreradEnhetEntry) IntegreradEnhet(se.inera.intyg.webcert.persistence.integreradenhet.model.IntegreradEnhet) Test(org.junit.Test)

Aggregations

IntegreradEnhetEntry (se.inera.intyg.webcert.web.integration.registry.dto.IntegreradEnhetEntry)8 IntegreradEnhet (se.inera.intyg.webcert.persistence.integreradenhet.model.IntegreradEnhet)5 Test (org.junit.Test)4 Vardenhet (se.inera.intyg.common.support.model.common.internal.Vardenhet)2 Vardgivare (se.inera.intyg.common.support.model.common.internal.Vardgivare)2 Transactional (org.springframework.transaction.annotation.Transactional)1 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)1