Skip to content

Commit

Permalink
refactor test shouldThrowNotAuthorizedExceptionWhenPermissionIsDenied
Browse files Browse the repository at this point in the history
  • Loading branch information
yvespp committed Dec 1, 2020
1 parent 5c8d92a commit 4fa0651
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import java.util.HashSet;
import java.util.Set;

import static org.junit.Assert.assertThrows;
import static org.mockito.Mockito.*;

public class CopyResourceTest {
Expand Down Expand Up @@ -86,7 +87,7 @@ public void shouldNotAllowCopyFromResourceOfDifferentType() throws Exception {
copyResource.doCopyResource(targetResourceId, originResourceId, ForeignableOwner.getSystemOwner());
}

@Test(expected = NotAuthorizedException.class)
@Test
public void shouldThrowNotAuthorizedExceptionWhenPermissionIsDenied() throws ForeignableOwnerViolationException, AMWException {
// given
ResourceEntity originResourceEntity = mock(ResourceEntity.class);
Expand All @@ -96,7 +97,9 @@ public void shouldThrowNotAuthorizedExceptionWhenPermissionIsDenied() throws For
when(originResourceEntity.getResourceType()).thenReturn(resourceType);

// when
copyResource.doCopyResource(targetResourceEntity, originResourceEntity, ForeignableOwner.AMW);
assertThrows(NotAuthorizedException.class, () -> {
copyResource.doCopyResource(targetResourceEntity, originResourceEntity, ForeignableOwner.AMW);
});

// then
verify(copyResourceDomainService, never()).copyFromOriginToTargetResource(originResourceEntity, targetResourceEntity, ForeignableOwner.AMW);
Expand Down

0 comments on commit 4fa0651

Please sign in to comment.