Search in sources :

Example 11 with IntegreradEnhet

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

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

the class IntegreradeEnheterRegistryImplTest method testDeleteIntegreradEnhet.

@Test
public void testDeleteIntegreradEnhet() {
    final String enhetsId = "enhetsId";
    IntegreradEnhet integreradEnhet = new IntegreradEnhet();
    when(integreradEnhetRepository.findOne(eq(enhetsId))).thenReturn(integreradEnhet);
    registry.deleteIntegreradEnhet(enhetsId);
    verify(integreradEnhetRepository).delete(integreradEnhet);
}
Also used : IntegreradEnhet(se.inera.intyg.webcert.persistence.integreradenhet.model.IntegreradEnhet) Test(org.junit.Test)

Example 13 with IntegreradEnhet

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

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

the class IntegreradeEnheterRegistryImplTest method testIsEnhetIntegreradTrue.

@Test
public void testIsEnhetIntegreradTrue() {
    final String enhetsId = "enhetsId";
    IntegreradEnhet enhet = new IntegreradEnhet();
    enhet.setSchemaVersion1(true);
    // exists
    when(integreradEnhetRepository.findOne(eq(enhetsId))).thenReturn(enhet);
    boolean result = registry.isEnhetIntegrerad(enhetsId, Fk7263EntryPoint.MODULE_ID);
    assertTrue(result);
}
Also used : IntegreradEnhet(se.inera.intyg.webcert.persistence.integreradenhet.model.IntegreradEnhet) Test(org.junit.Test)

Example 15 with IntegreradEnhet

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

the class IntegreradeEnheterRegistryImplTest method testGetSchemaVersionNotFound.

@Test
public void testGetSchemaVersionNotFound() {
    final String enhetsId = "enhetsid";
    IntegreradEnhet enhet = new IntegreradEnhet();
    enhet.setSchemaVersion1(false);
    enhet.setSchemaVersion3(false);
    when(integreradEnhetRepository.findOne(eq(enhetsId))).thenReturn(enhet);
    assertFalse(registry.getSchemaVersion(enhetsId, Fk7263EntryPoint.MODULE_ID).isPresent());
    assertFalse(registry.getSchemaVersion(enhetsId, LuseEntryPoint.MODULE_ID).isPresent());
}
Also used : 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