use of se.inera.intyg.webcert.persistence.anvandarmetadata.model.AnvandarPreference in project webcert by sklintyg.
the class AnvandarPreferenceRepositoryTest method buildAnvandarPreference.
private AnvandarPreference buildAnvandarPreference(String hsaId, String key, String value) {
AnvandarPreference am = new AnvandarPreference();
am.setHsaId(hsaId);
am.setKey(key);
am.setValue(value);
return am;
}
use of se.inera.intyg.webcert.persistence.anvandarmetadata.model.AnvandarPreference in project webcert by sklintyg.
the class AnvandarPreferenceRepositoryTest method testFindOne.
@Test
public void testFindOne() {
AnvandarPreference saved = buildAnvandarPreference(HSA_ID, KEY_1, VALUE_1);
anvandarMetadataRepository.save(saved);
AnvandarPreference read = anvandarMetadataRepository.findOne(saved.getInternReferens());
assertEquals(saved, read);
}
use of se.inera.intyg.webcert.persistence.anvandarmetadata.model.AnvandarPreference in project webcert by sklintyg.
the class AnvandarPreferenceRepositoryTest method testGetAnvandarPreference.
@Test
public void testGetAnvandarPreference() {
AnvandarPreference saved = buildAnvandarPreference(HSA_ID, KEY_1, VALUE_1);
anvandarMetadataRepository.save(saved);
AnvandarPreference saved2 = buildAnvandarPreference(HSA_ID, KEY_2, VALUE_2);
anvandarMetadataRepository.save(saved2);
AnvandarPreference savedOther = buildAnvandarPreference("other-id", "key3", "value3");
anvandarMetadataRepository.save(savedOther);
Map<String, String> anvandarPref = anvandarMetadataRepository.getAnvandarPreference(HSA_ID);
assertEquals(2, anvandarPref.size());
assertEquals(VALUE_1, anvandarPref.get(KEY_1));
assertEquals(VALUE_2, anvandarPref.get(KEY_2));
}
use of se.inera.intyg.webcert.persistence.anvandarmetadata.model.AnvandarPreference in project webcert by sklintyg.
the class WebCertUserServiceImpl method deleteUserPreference.
@Override
public void deleteUserPreference(String key) {
WebCertUser user = getUser();
String hsaId = user.getHsaId();
AnvandarPreference am = anvandarPreferenceRepository.findByHsaIdAndKey(hsaId, key);
if (am != null) {
anvandarPreferenceRepository.delete(am);
}
user.getAnvandarPreference().remove(key);
}
use of se.inera.intyg.webcert.persistence.anvandarmetadata.model.AnvandarPreference in project webcert by sklintyg.
the class WebCertUserServiceTest method testStoreExistingUserMetadata.
@Test
public void testStoreExistingUserMetadata() {
WebCertUser user = createWebCertUser(false);
applyUserToThreadLocalCtx(user);
when(anvandarPreferenceRepository.findByHsaIdAndKey("HSA-id", "key1")).thenReturn(new AnvandarPreference("HSA-id", "key1", "value1"));
webcertUserService.storeUserPreference("key1", "value1");
assertEquals("value1", user.getAnvandarPreference().get("key1"));
verify(anvandarPreferenceRepository, times(1)).findByHsaIdAndKey("HSA-id", "key1");
verify(anvandarPreferenceRepository, times(1)).save(any(AnvandarPreference.class));
}
Aggregations