@Test public void getAuthenticatedExperimentById() throws Exception { when(authorization.getUser("foo")).thenReturn(username); when(experiments.getExperiment(experimentId)).thenReturn(experiment); when(experiment.getApplicationName()).thenReturn(applicationName); authorizedExperimentGetter.getAuthorizedExperimentById("foo", experimentId); verify(authorization).getUser("foo"); verify(experiments).getExperiment(experimentId); verify(authorization).checkUserPermissions(username, applicationName, READ); }
Experiment getAuthorizedExperimentById(final String authorizationHeader, final Experiment.ID experimentId) { UserInfo.Username userName = authorization.getUser(authorizationHeader); Experiment experiment = experiments.getExperiment(experimentId); if (experiment == null) { throw new ExperimentNotFoundException(experimentId); } authorization.checkUserPermissions(userName, experiment.getApplicationName(), READ); return experiment; }
AuthorizedExperimentGetter { Experiment getAuthorizedExperimentById(final String authorizationHeader, final Experiment.ID experimentId) { UserInfo.Username userName = authorization.getUser(authorizationHeader); Experiment experiment = experiments.getExperiment(experimentId); if (experiment == null) { throw new ExperimentNotFoundException(experimentId); } authorization.checkUserPermissions(userName, experiment.getApplicationName(), READ); return experiment; } }
AuthorizedExperimentGetter { Experiment getAuthorizedExperimentById(final String authorizationHeader, final Experiment.ID experimentId) { UserInfo.Username userName = authorization.getUser(authorizationHeader); Experiment experiment = experiments.getExperiment(experimentId); if (experiment == null) { throw new ExperimentNotFoundException(experimentId); } authorization.checkUserPermissions(userName, experiment.getApplicationName(), READ); return experiment; } @Inject  AuthorizedExperimentGetter(final Authorization authorization, final Experiments experiments); }
AuthorizedExperimentGetter { Experiment getAuthorizedExperimentById(final String authorizationHeader, final Experiment.ID experimentId) { UserInfo.Username userName = authorization.getUser(authorizationHeader); Experiment experiment = experiments.getExperiment(experimentId); if (experiment == null) { throw new ExperimentNotFoundException(experimentId); } authorization.checkUserPermissions(userName, experiment.getApplicationName(), READ); return experiment; } @Inject  AuthorizedExperimentGetter(final Authorization authorization, final Experiments experiments);  }
AuthorizedExperimentGetter { Experiment getAuthorizedExperimentById(final String authorizationHeader, final Experiment.ID experimentId) { UserInfo.Username userName = authorization.getUser(authorizationHeader); Experiment experiment = experiments.getExperiment(experimentId); if (experiment == null) { throw new ExperimentNotFoundException(experimentId); } authorization.checkUserPermissions(userName, experiment.getApplicationName(), READ); return experiment; } @Inject  AuthorizedExperimentGetter(final Authorization authorization, final Experiments experiments);   }