Search in sources :

Example 16 with IntegreradEnhet

use of se.inera.intyg.webcert.persistence.integreradenhet.model.IntegreradEnhet 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)

Example 17 with IntegreradEnhet

use of se.inera.intyg.webcert.persistence.integreradenhet.model.IntegreradEnhet in project webcert by sklintyg.

the class IntegreradeEnheterRegistryImplTest method testGetSchemaVersionOldV3Found.

@Test
public void testGetSchemaVersionOldV3Found() {
    final String enhetsId = "enhetsid";
    IntegreradEnhet enhet = new IntegreradEnhet();
    enhet.setSchemaVersion1(true);
    enhet.setSchemaVersion3(true);
    when(integreradEnhetRepository.findOne(eq(enhetsId))).thenReturn(enhet);
    Optional<SchemaVersion> result = registry.getSchemaVersion(enhetsId, Fk7263EntryPoint.MODULE_ID);
    assertTrue(result.isPresent());
    assertEquals(SchemaVersion.VERSION_3, result.get());
}
Also used : SchemaVersion(se.inera.intyg.common.support.modules.support.api.notification.SchemaVersion) IntegreradEnhet(se.inera.intyg.webcert.persistence.integreradenhet.model.IntegreradEnhet) Test(org.junit.Test)

Aggregations

IntegreradEnhet (se.inera.intyg.webcert.persistence.integreradenhet.model.IntegreradEnhet)17 Test (org.junit.Test)12 IntegreradEnhetEntry (se.inera.intyg.webcert.web.integration.registry.dto.IntegreradEnhetEntry)5 Transactional (org.springframework.transaction.annotation.Transactional)3 SchemaVersion (se.inera.intyg.common.support.modules.support.api.notification.SchemaVersion)3 IOException (java.io.IOException)1 CustomObjectMapper (se.inera.intyg.common.util.integration.json.CustomObjectMapper)1