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