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());
}
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);
}
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());
}
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);
}
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());
}
Aggregations