Skip to content

Commit

Permalink
Updated tests
Browse files Browse the repository at this point in the history
Signed-off-by: SimoneFiorani <[email protected]>
  • Loading branch information
sfiorani committed Dec 7, 2023
1 parent a3d85e3 commit d38294f
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package org.eclipse.kura.internal.rest.identity.provider.test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
Expand Down Expand Up @@ -186,6 +187,24 @@ public void shouldNotValidateWrongPassword() {
thenPasswordValidationIs(false);
}

@Test
public void shouldThrowExceptionWhenDeletingNonExistingUser() {
givenIdentityService();

whenDeleting("NonExistingUser");

thenExceptionOccurred(KuraException.class);
}

@Test
public void shouldThrowExceptionWhenGettingNonExistingUser() {
givenIdentityService();

whenGettingUser("NonExistingUser");

thenExceptionOccurred(KuraException.class);
}

private void whenValidatingPassword(String password) {
try {
this.identityService.validateUserPassword(password);
Expand Down Expand Up @@ -330,6 +349,11 @@ private void thenNoExceptionOccurred() {
assertNull(errorMessage, this.occurredException);
}

private <E extends Exception> void thenExceptionOccurred(Class<E> expectedExceptionClass) {
assertNotNull(this.occurredException);
assertEquals(expectedExceptionClass.getName(), this.occurredException.getClass().getName());
}

public static class PermissionRole implements Group {

private final String name;
Expand Down

0 comments on commit d38294f

Please sign in to comment.