@Test public void testGetSchemaVersionOldV3Found() { final String enhetsId = "enhetsid"; IntegreradEnhet enhet = new IntegreradEnhet(); enhet.setSchemaVersion1(true); enhet.setSchemaVersion3(true); when(integreradEnhetRepository.findById(eq(enhetsId))).thenReturn(Optional.of(enhet)); Optional<SchemaVersion> result = registry.getSchemaVersion(enhetsId, Fk7263EntryPoint.MODULE_ID); assertTrue(result.isPresent()); assertEquals(SchemaVersion.VERSION_3, result.get()); }
@Override @Transactional public Optional<SchemaVersion> getSchemaVersion(String enhetsHsaId, String intygType) { IntegreradEnhet enhet = getIntegreradEnhetAndUpdateControlDate(enhetsHsaId); if (enhet == null) { return Optional.empty(); } if (!oldIntygTypes.contains(intygType)) { return enhet.isSchemaVersion3() ? Optional.of(SchemaVersion.VERSION_3) : Optional.empty(); } else if (!enhet.isSchemaVersion1()) { return Optional.empty(); } else { return enhet.isSchemaVersion3() ? Optional.of(SchemaVersion.VERSION_3) : Optional.of(SchemaVersion.VERSION_1); } }
IntegreradeEnheterRegistryImpl implements IntegreradeEnheterRegistry { @Override @Transactional public Optional<SchemaVersion> getSchemaVersion(String enhetsHsaId, String intygType) { IntegreradEnhet enhet = getIntegreradEnhetAndUpdateControlDate(enhetsHsaId); if (enhet == null) { return Optional.empty(); } if (!oldIntygTypes.contains(intygType)) { return enhet.isSchemaVersion3() ? Optional.of(SchemaVersion.VERSION_3) : Optional.empty(); } else if (!enhet.isSchemaVersion1()) { return Optional.empty(); } else { return enhet.isSchemaVersion3() ? Optional.of(SchemaVersion.VERSION_3) : Optional.of(SchemaVersion.VERSION_1); } } }
IntegreradeEnheterRegistryImpl implements IntegreradeEnheterRegistry { @Override @Transactional public Optional<SchemaVersion> getSchemaVersion(String enhetsHsaId, String intygType) { IntegreradEnhet enhet = getIntegreradEnhetAndUpdateControlDate(enhetsHsaId); if (enhet == null) { return Optional.empty(); } if (!oldIntygTypes.contains(intygType)) { return enhet.isSchemaVersion3() ? Optional.of(SchemaVersion.VERSION_3) : Optional.empty(); } else if (!enhet.isSchemaVersion1()) { return Optional.empty(); } else { return enhet.isSchemaVersion3() ? Optional.of(SchemaVersion.VERSION_3) : Optional.of(SchemaVersion.VERSION_1); } }  }
IntegreradeEnheterRegistryImpl implements IntegreradeEnheterRegistry { @Override @Transactional public Optional<SchemaVersion> getSchemaVersion(String enhetsHsaId, String intygType) { IntegreradEnhet enhet = getIntegreradEnhetAndUpdateControlDate(enhetsHsaId); if (enhet == null) { return Optional.empty(); } if (!oldIntygTypes.contains(intygType)) { return enhet.isSchemaVersion3() ? Optional.of(SchemaVersion.VERSION_3) : Optional.empty(); } else if (!enhet.isSchemaVersion1()) { return Optional.empty(); } else { return enhet.isSchemaVersion3() ? Optional.of(SchemaVersion.VERSION_3) : Optional.of(SchemaVersion.VERSION_1); } }  @Override @Transactional void putIntegreradEnhet(IntegreradEnhetEntry entry, boolean schemaVersion1, boolean schemaVersion3); @Override @Transactional boolean isEnhetIntegrerad(String enhetsHsaId, String intygType); @Override @Transactional(readOnly = true) IntegreradEnhet getIntegreradEnhet(String enhetsId); @Override @Transactional(readOnly = true) List<IntegreradEnhet> getAllIntegreradEnhet(); @Override @Transactional void addIfSameVardgivareButDifferentUnits(String orgEnhetsHsaId, IntegreradEnhetEntry newEntry, String intygType); @Override @Transactional void deleteIntegreradEnhet(String enhetsHsaId); @Override @Transactional Optional<SchemaVersion> getSchemaVersion(String enhetsHsaId, String intygType); @Override @Transactional(readOnly = true) List<IntegreradEnhetEntryWithSchemaVersion> getIntegreradeVardenheter(); }
IntegreradeEnheterRegistryImpl implements IntegreradeEnheterRegistry { @Override @Transactional public Optional<SchemaVersion> getSchemaVersion(String enhetsHsaId, String intygType) { IntegreradEnhet enhet = getIntegreradEnhetAndUpdateControlDate(enhetsHsaId); if (enhet == null) { return Optional.empty(); } if (!oldIntygTypes.contains(intygType)) { return enhet.isSchemaVersion3() ? Optional.of(SchemaVersion.VERSION_3) : Optional.empty(); } else if (!enhet.isSchemaVersion1()) { return Optional.empty(); } else { return enhet.isSchemaVersion3() ? Optional.of(SchemaVersion.VERSION_3) : Optional.of(SchemaVersion.VERSION_1); } }  @Override @Transactional void putIntegreradEnhet(IntegreradEnhetEntry entry, boolean schemaVersion1, boolean schemaVersion3); @Override @Transactional boolean isEnhetIntegrerad(String enhetsHsaId, String intygType); @Override @Transactional(readOnly = true) IntegreradEnhet getIntegreradEnhet(String enhetsId); @Override @Transactional(readOnly = true) List<IntegreradEnhet> getAllIntegreradEnhet(); @Override @Transactional void addIfSameVardgivareButDifferentUnits(String orgEnhetsHsaId, IntegreradEnhetEntry newEntry, String intygType); @Override @Transactional void deleteIntegreradEnhet(String enhetsHsaId); @Override @Transactional Optional<SchemaVersion> getSchemaVersion(String enhetsHsaId, String intygType); @Override @Transactional(readOnly = true) List<IntegreradEnhetEntryWithSchemaVersion> getIntegreradeVardenheter();  }