@Test public void authorizationForReturnsAnEmptyOptionalIfTheVreAuthorizationIsNotFound() throws Exception { Optional<VreAuthorization> vreAuthorization = instance.getAuthorization(VRE, "unknownUser"); assertThat(vreAuthorization, is(not(present()))); }
@Override public Optional<VreAuthorization> getAuthorization(String vreId, String userId) throws AuthorizationUnavailableException { Optional<VreAuthorization> authorizationValue = Optional.empty(); File file = getFileOfVre(vreId); authorizationValue = getAuthorization(userId, authorizationValue, file); if (!authorizationValue.isPresent()) { file = authorizationsFolder.resolve("authorizations.json").toFile(); authorizationValue = getAuthorization(userId, authorizationValue, file); } return authorizationValue; }
LocalFileVreAuthorizationAccess implements VreAuthorizationAccess { @Override public Optional<VreAuthorization> getAuthorization(String vreId, String userId) throws AuthorizationUnavailableException { Optional<VreAuthorization> authorizationValue = Optional.empty(); File file = getFileOfVre(vreId); authorizationValue = getAuthorization(userId, authorizationValue, file); if (!authorizationValue.isPresent()) { file = authorizationsFolder.resolve("authorizations.json").toFile(); authorizationValue = getAuthorization(userId, authorizationValue, file); } return authorizationValue; } }
LocalFileVreAuthorizationAccess implements VreAuthorizationAccess { @Override public Optional<VreAuthorization> getAuthorization(String vreId, String userId) throws AuthorizationUnavailableException { Optional<VreAuthorization> authorizationValue = Optional.empty(); File file = getFileOfVre(vreId); authorizationValue = getAuthorization(userId, authorizationValue, file); if (!authorizationValue.isPresent()) { file = authorizationsFolder.resolve("authorizations.json").toFile(); authorizationValue = getAuthorization(userId, authorizationValue, file); } return authorizationValue; } LocalFileVreAuthorizationAccess(Path authorizationsFolder); }
LocalFileVreAuthorizationAccess implements VreAuthorizationAccess { @Override public Optional<VreAuthorization> getAuthorization(String vreId, String userId) throws AuthorizationUnavailableException { Optional<VreAuthorization> authorizationValue = Optional.empty(); File file = getFileOfVre(vreId); authorizationValue = getAuthorization(userId, authorizationValue, file); if (!authorizationValue.isPresent()) { file = authorizationsFolder.resolve("authorizations.json").toFile(); authorizationValue = getAuthorization(userId, authorizationValue, file); } return authorizationValue; } LocalFileVreAuthorizationAccess(Path authorizationsFolder); @Override VreAuthorization getOrCreateAuthorization(String vreId, String userId, String userRole); @Override Optional<VreAuthorization> getAuthorization(String vreId, String userId); @Override void deleteVreAuthorizations(String vreId); }
LocalFileVreAuthorizationAccess implements VreAuthorizationAccess { @Override public Optional<VreAuthorization> getAuthorization(String vreId, String userId) throws AuthorizationUnavailableException { Optional<VreAuthorization> authorizationValue = Optional.empty(); File file = getFileOfVre(vreId); authorizationValue = getAuthorization(userId, authorizationValue, file); if (!authorizationValue.isPresent()) { file = authorizationsFolder.resolve("authorizations.json").toFile(); authorizationValue = getAuthorization(userId, authorizationValue, file); } return authorizationValue; } LocalFileVreAuthorizationAccess(Path authorizationsFolder); @Override VreAuthorization getOrCreateAuthorization(String vreId, String userId, String userRole); @Override Optional<VreAuthorization> getAuthorization(String vreId, String userId); @Override void deleteVreAuthorizations(String vreId); static final Logger LOG; }