### Question:
BasicPermissionFetcher implements PermissionFetcher { @Override public void initializeOwnerAuthorization(User user, String ownerId, String dataSetId) throws AuthorizationCreationException { String vreId = createCombinedId(ownerId, dataSetId); try { vreAuthorizationCrud.createAuthorization(vreId, user, "ADMIN"); } catch (AuthorizationCreationException e) { LOG.error("Could not initialize VRE Authorization {}", vreId); LOG.error("Exception thrown", e); throw e; } } BasicPermissionFetcher(VreAuthorizationCrud vreAuthorizationCrud, PermissionConfiguration permissionConfig); @Override Set<Permission> getPermissions(User user, DataSetMetaData dataSetMetadata); @Override boolean hasPermission(User user, DataSetMetaData dataSet, Permission permission); @Override @Deprecated Set<Permission> getOldPermissions(User user, String vreId); @Override void initializeOwnerAuthorization(User user, String ownerId, String dataSetId); @Override void removeAuthorizations(String vreId);  }### Answer:
@Test public void initializeOwnerAuthorizationCreatesAdminAuthorization() throws Exception { User user = userWithId("testuserid"); permissionFetcher.initializeOwnerAuthorization(user,"testownerid", "testdatasetid"); verify(vreAuthorizationCrud).createAuthorization("testownerid__testdatasetid", user, "ADMIN"); }
@Test(expected = AuthorizationCreationException.class) public void initializeOwnerAuthorizationThrowsExceptionWhenVreAuthorizationCrudFails() throws Exception { User user = userWithId("testuserid"); doThrow(AuthorizationCreationException.class).when(vreAuthorizationCrud).createAuthorization( "testownerid__testdatasetid", user, "ADMIN" ); permissionFetcher.initializeOwnerAuthorization(user,"testownerid", "testdatasetid"); }