@Test(expected = AuthenticationException.class) public void getAuthenticatedExperimentByNameWithBadUser() throws Exception { when(authorization.getUser("foo")).thenThrow(new AuthenticationException("bad auth")); authorizedExperimentGetter.getAuthorizedExperimentByName("foo", applicationName, experimentLabel); verify(authorization, times(0)).getUser("foo"); verify(authorization, times(0)).checkUserPermissions(username, applicationName, READ); verify(experiments, times(0)).getExperiment(applicationName, experimentLabel); }
Experiment getAuthorizedExperimentByName(final String authorizationHeader, final Application.Name applicationName, final Experiment.Label experimentLabel) { authorization.checkUserPermissions(authorization.getUser(authorizationHeader), applicationName, READ); Experiment experiment = experiments.getExperiment(applicationName, experimentLabel); if (experiment == null) { throw new ExperimentNotFoundException(experimentLabel); } return experiment; }
AuthorizedExperimentGetter { Experiment getAuthorizedExperimentByName(final String authorizationHeader, final Application.Name applicationName, final Experiment.Label experimentLabel) { authorization.checkUserPermissions(authorization.getUser(authorizationHeader), applicationName, READ); Experiment experiment = experiments.getExperiment(applicationName, experimentLabel); if (experiment == null) { throw new ExperimentNotFoundException(experimentLabel); } return experiment; } }
AuthorizedExperimentGetter { Experiment getAuthorizedExperimentByName(final String authorizationHeader, final Application.Name applicationName, final Experiment.Label experimentLabel) { authorization.checkUserPermissions(authorization.getUser(authorizationHeader), applicationName, READ); Experiment experiment = experiments.getExperiment(applicationName, experimentLabel); if (experiment == null) { throw new ExperimentNotFoundException(experimentLabel); } return experiment; } @Inject  AuthorizedExperimentGetter(final Authorization authorization, final Experiments experiments); }
AuthorizedExperimentGetter { Experiment getAuthorizedExperimentByName(final String authorizationHeader, final Application.Name applicationName, final Experiment.Label experimentLabel) { authorization.checkUserPermissions(authorization.getUser(authorizationHeader), applicationName, READ); Experiment experiment = experiments.getExperiment(applicationName, experimentLabel); if (experiment == null) { throw new ExperimentNotFoundException(experimentLabel); } return experiment; } @Inject  AuthorizedExperimentGetter(final Authorization authorization, final Experiments experiments);  }
AuthorizedExperimentGetter { Experiment getAuthorizedExperimentByName(final String authorizationHeader, final Application.Name applicationName, final Experiment.Label experimentLabel) { authorization.checkUserPermissions(authorization.getUser(authorizationHeader), applicationName, READ); Experiment experiment = experiments.getExperiment(applicationName, experimentLabel); if (experiment == null) { throw new ExperimentNotFoundException(experimentLabel); } return experiment; } @Inject  AuthorizedExperimentGetter(final Authorization authorization, final Experiments experiments);   }