Search in sources :

Example 1 with IntegreradEnhet

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

the class IntegreradEnhetRepositoryTest method testSaveIntegreradEnhet.

@Test
public void testSaveIntegreradEnhet() {
    IntegreradEnhet enhet = new IntegreradEnhet();
    enhet.setEnhetsId("SE1234567890-1A01");
    enhet.setEnhetsNamn("Enhet 1");
    enhet.setVardgivarId("SE1234567890-2B01");
    enhet.setVardgivarNamn("Vardgivare 1");
    enhet.setSchemaVersion1(true);
    enhet.setSchemaVersion3(false);
    IntegreradEnhet savedEnhet = repository.save(enhet);
    assertNotNull(savedEnhet);
    assertNotNull(savedEnhet.getSkapadDatum());
    assertNull(savedEnhet.getSenasteKontrollDatum());
    assertTrue(savedEnhet.isSchemaVersion1());
    assertFalse(savedEnhet.isSchemaVersion3());
}
Also used : IntegreradEnhet(se.inera.intyg.webcert.persistence.integreradenhet.model.IntegreradEnhet) Test(org.junit.Test)

Example 2 with IntegreradEnhet

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

the class IntegreradeEnheterRegistryImplTest method testGetSchemaVersionOldV1Found.

@Test
public void testGetSchemaVersionOldV1Found() {
    final String enhetsId = "enhetsid";
    IntegreradEnhet enhet = new IntegreradEnhet();
    enhet.setSchemaVersion1(true);
    when(integreradEnhetRepository.findOne(eq(enhetsId))).thenReturn(enhet);
    Optional<SchemaVersion> result = registry.getSchemaVersion(enhetsId, Fk7263EntryPoint.MODULE_ID);
    assertTrue(result.isPresent());
    assertEquals(SchemaVersion.VERSION_1, 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)

Example 3 with IntegreradEnhet

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

the class IntegreradeEnheterRegistryImplTest method testGetSchemaVersionNewFound.

@Test
public void testGetSchemaVersionNewFound() {
    final String enhetsId = "enhetsid";
    IntegreradEnhet enhet = new IntegreradEnhet();
    enhet.setSchemaVersion1(false);
    enhet.setSchemaVersion3(true);
    when(integreradEnhetRepository.findOne(enhetsId)).thenReturn(enhet);
    Optional<SchemaVersion> result = registry.getSchemaVersion(enhetsId, LuseEntryPoint.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)

Example 4 with IntegreradEnhet

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

the class IntegreradeEnheterRegistryImplTest method testPutIntegreradEnhetSetsSchemaVersion.

@Test
public void testPutIntegreradEnhetSetsSchemaVersion() {
    final String enhetsId = "enhetsId";
    IntegreradEnhetEntry entry = new IntegreradEnhetEntry(enhetsId, "vardgivareId");
    // not found
    when(integreradEnhetRepository.findOne(enhetsId)).thenReturn(null);
    when(integreradEnhetRepository.save(any(IntegreradEnhet.class))).thenReturn(new IntegreradEnhet());
    registry.putIntegreradEnhet(entry, false, true);
    ArgumentCaptor<IntegreradEnhet> enhetCaptor = ArgumentCaptor.forClass(IntegreradEnhet.class);
    verify(integreradEnhetRepository).save(enhetCaptor.capture());
    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 5 with IntegreradEnhet

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

the class IntegreradeEnheterRegistryImpl method addIfSameVardgivareButDifferentUnits.

@Override
@Transactional("jpaTransactionManager")
public void addIfSameVardgivareButDifferentUnits(String orgEnhetsHsaId, IntegreradEnhetEntry newEntry, String intygType) {
    if (getSchemaVersion(orgEnhetsHsaId, intygType).isPresent()) {
        IntegreradEnhet enhet = getIntegreradEnhet(orgEnhetsHsaId);
        IntegreradEnhetEntry orgEntry = getIntegreradEnhetEntry(enhet);
        if (orgEntry != null && orgEntry.compareTo(newEntry) != 0) {
            putIntegreradEnhet(newEntry, enhet.isSchemaVersion1(), enhet.isSchemaVersion3());
        }
    }
}
Also used : IntegreradEnhetEntry(se.inera.intyg.webcert.web.integration.registry.dto.IntegreradEnhetEntry) IntegreradEnhet(se.inera.intyg.webcert.persistence.integreradenhet.model.IntegreradEnhet) Transactional(org.springframework.transaction.annotation.Transactional)

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