SamPermissionsImpl implements PermissionsInterface { <T> Optional<T> readValue(ApiException e, Class<T> clazz) { String body = e.getResponseBody(); return readValue(body, clazz); } SamPermissionsImpl(TokenDAO tokenDAO, DockstoreWebserviceConfiguration config); @Override List<Permission> setPermission(User requester, Workflow workflow, Permission permission); @Override Map<Role, List<String>> workflowsSharedWithUser(User user); @Override List<Permission> getPermissionsForWorkflow(User user, Workflow workflow); @Override List<Role.Action> getActionsForWorkflow(User user, Workflow workflow); @Override void removePermission(User user, Workflow workflow, String email, Role role); @Override boolean canDoAction(User user, Workflow workflow, Role.Action action); @Override void selfDestruct(User user); @Override boolean isSharing(User user);  }
@Test public void testReadValue() { String response = "{\n" + "\"statusCode\": 400,\n" + "\"source\": \"sam\",\n" + "\"causes\": [],\n" + "\"stackTrace\": [],\n" + "\"message\": \"jane_doe@yahoo.com not found\"\n" + "}"; Optional<ErrorReport> errorReport = samPermissionsImpl.readValue(response, ErrorReport.class); Assert.assertEquals(errorReport.get().getMessage(), "jane_doe@yahoo.com not found"); Assert.assertFalse(samPermissionsImpl.readValue((String)null, ErrorReport.class).isPresent()); }