Search in sources :

Example 6 with AnvandarPreference

use of se.inera.intyg.webcert.persistence.anvandarmetadata.model.AnvandarPreference in project webcert by sklintyg.

the class WebCertUserServiceTest method testDeleteStoredAnvandarPreference.

@Test
public void testDeleteStoredAnvandarPreference() {
    AnvandarPreference anvandarPreference = new AnvandarPreference("HSA-id", "key1", "value1");
    WebCertUser user = createWebCertUser(false);
    applyUserToThreadLocalCtx(user);
    when(anvandarPreferenceRepository.findByHsaIdAndKey(user.getHsaId(), "key1")).thenReturn(anvandarPreference);
    webcertUserService.deleteUserPreference("key1");
    verify(anvandarPreferenceRepository, times(1)).findByHsaIdAndKey("HSA-id", "key1");
    verify(anvandarPreferenceRepository, times(1)).delete(anvandarPreference);
}
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)

Example 7 with AnvandarPreference

use of se.inera.intyg.webcert.persistence.anvandarmetadata.model.AnvandarPreference in project webcert by sklintyg.

the class WebCertUserServiceTest method testDeleteAllAnvandarPreferences.

@Test
public void testDeleteAllAnvandarPreferences() {
    WebCertUser user = createWebCertUser(false);
    applyUserToThreadLocalCtx(user);
    when(anvandarPreferenceRepository.getAnvandarPreference(user.getHsaId())).thenReturn(buildMapOfAllUserPrefs());
    when(anvandarPreferenceRepository.findByHsaIdAndKey(user.getHsaId(), "key1")).thenReturn(new AnvandarPreference());
    when(anvandarPreferenceRepository.findByHsaIdAndKey(user.getHsaId(), "key2")).thenReturn(new AnvandarPreference());
    webcertUserService.deleteUserPreferences();
    verify(anvandarPreferenceRepository, times(1)).findByHsaIdAndKey("HSA-id", "key1");
    verify(anvandarPreferenceRepository, times(1)).findByHsaIdAndKey("HSA-id", "key2");
    verify(anvandarPreferenceRepository, times(2)).delete(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)

Example 8 with AnvandarPreference

use of se.inera.intyg.webcert.persistence.anvandarmetadata.model.AnvandarPreference in project webcert by sklintyg.

the class AnvandarPreferenceRepositoryTest method testFindByHsaAndKeyWhenNotExists.

@Test
public void testFindByHsaAndKeyWhenNotExists() {
    AnvandarPreference anvandarPreference = anvandarMetadataRepository.findByHsaIdAndKey(HSA_ID, KEY_1);
    assertNull(anvandarPreference);
}
Also used : AnvandarPreference(se.inera.intyg.webcert.persistence.anvandarmetadata.model.AnvandarPreference) Test(org.junit.Test)

Example 9 with AnvandarPreference

use of se.inera.intyg.webcert.persistence.anvandarmetadata.model.AnvandarPreference in project webcert by sklintyg.

the class AnvandarPreferenceRepositoryTest method testFindByHsaAndKey.

@Test
public void testFindByHsaAndKey() {
    AnvandarPreference saved = buildAnvandarPreference(HSA_ID, KEY_1, VALUE_1);
    anvandarMetadataRepository.save(saved);
    AnvandarPreference anvandarPreference = anvandarMetadataRepository.findByHsaIdAndKey(HSA_ID, KEY_1);
    assertEquals(saved, anvandarPreference);
}
Also used : AnvandarPreference(se.inera.intyg.webcert.persistence.anvandarmetadata.model.AnvandarPreference) Test(org.junit.Test)

Example 10 with AnvandarPreference

use of se.inera.intyg.webcert.persistence.anvandarmetadata.model.AnvandarPreference in project webcert by sklintyg.

the class AnvandarPreferenceRepositoryTest method testDeleteAnvandarPreferenceThatExists.

@Test
public void testDeleteAnvandarPreferenceThatExists() {
    AnvandarPreference saved = buildAnvandarPreference(HSA_ID, KEY_1, VALUE_1);
    anvandarMetadataRepository.save(saved);
    anvandarMetadataRepository.delete(saved);
    boolean exists = anvandarMetadataRepository.exists(HSA_ID, KEY_1);
    assertFalse(exists);
    Map<String, String> anvandarPreferenceMap = anvandarMetadataRepository.getAnvandarPreference(HSA_ID);
    assertEquals(0, anvandarPreferenceMap.size());
}
Also used : AnvandarPreference(se.inera.intyg.webcert.persistence.anvandarmetadata.model.AnvandarPreference) 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