Search in sources :

Example 1 with AnvandarPreference

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;
}
Also used : AnvandarPreference(se.inera.intyg.webcert.persistence.anvandarmetadata.model.AnvandarPreference)

Example 2 with AnvandarPreference

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);
}
Also used : AnvandarPreference(se.inera.intyg.webcert.persistence.anvandarmetadata.model.AnvandarPreference) Test(org.junit.Test)

Example 3 with AnvandarPreference

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));
}
Also used : AnvandarPreference(se.inera.intyg.webcert.persistence.anvandarmetadata.model.AnvandarPreference) Test(org.junit.Test)

Example 4 with AnvandarPreference

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);
}
Also used : AnvandarPreference(se.inera.intyg.webcert.persistence.anvandarmetadata.model.AnvandarPreference) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Example 5 with AnvandarPreference

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));
}
Also used : AnvandarPreference(se.inera.intyg.webcert.persistence.anvandarmetadata.model.AnvandarPreference) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Test(org.junit.Test)

Aggregations

AnvandarPreference (se.inera.intyg.webcert.persistence.anvandarmetadata.model.AnvandarPreference)13 Test (org.junit.Test)8 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)6 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1