### Question:
JsonBasedAuthorizer implements VreAuthorizationCrud { @Override public void createAuthorization(String vreId, User user, String vreRole) throws AuthorizationCreationException { try { authorizationAccess.getOrCreateAuthorization(vreId, user.getPersistentId(), vreRole); } catch (AuthorizationUnavailableException e) { throw new AuthorizationCreationException(e); } } JsonBasedAuthorizer(VreAuthorizationAccess authorizationAccess); @Override Optional<VreAuthorization> getAuthorization(String vreId, User user); @Override void createAuthorization(String vreId, User user, String vreRole); @Override void deleteVreAuthorizations(String vreId);  }### Answer:
@Test public void createAuthorizationLetsCreatesANewAuthorizationForTheUserVreAndRole() throws Exception { instance.createAuthorization(VRE_ID, userWithPid(USER_PID), UserRoles.USER_ROLE); verify(authorizationAccess).getOrCreateAuthorization(VRE_ID, USER_PID, UserRoles.USER_ROLE); }
@Test(expected = AuthorizationCreationException.class) public void createAuthorizationThrowsAnAuthCreateExWhenTheAuthorizationCollectionThrowsAnAuthUnavailableEx() throws Exception { when(authorizationAccess.getOrCreateAuthorization(anyString(), anyString(), anyString())) .thenThrow(new AuthorizationUnavailableException()); instance.createAuthorization(VRE_ID, userWithPid(USER_PID), UserRoles.USER_ROLE); }