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