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