@Test public void testCheckStateTransition() { Experiment.State currentState = Experiment.State.RUNNING; Experiment.State desiredState = Experiment.State.RUNNING; verify(validator, never()).validateStateTransition(currentState, desiredState); expImpl.checkStateTransition(experimentID, currentState, desiredState); verify(validator, never()).validateStateTransition(currentState, desiredState); expImpl.checkStateTransition(experimentID, currentState, null); BucketList bucketList = mock(BucketList.class); when(buckets.getBuckets(experimentID, false)).thenReturn(bucketList); expImpl.checkStateTransition(experimentID, Experiment.State.DRAFT, Experiment.State.RUNNING); verify(validator, times(1)).validateStateTransition(Experiment.State.DRAFT, Experiment.State.RUNNING); verify(buckets, times(1)).getBuckets(experimentID, false); verify(validator, times(1)).validateExperimentBuckets(bucketList.getBuckets()); }
@Override public void checkStateTransition(Experiment.ID experimentID, Experiment.State currentState, Experiment.State desiredState) { if (desiredState != null && !currentState.equals(desiredState)) { validator.validateStateTransition(currentState, desiredState); if (currentState.equals(DRAFT) && desiredState.equals(RUNNING)) { BucketList bucketList = buckets.getBuckets(experimentID, false ); validator.validateExperimentBuckets(bucketList.getBuckets()); } } }
ExperimentsImpl implements Experiments { @Override public void checkStateTransition(Experiment.ID experimentID, Experiment.State currentState, Experiment.State desiredState) { if (desiredState != null && !currentState.equals(desiredState)) { validator.validateStateTransition(currentState, desiredState); if (currentState.equals(DRAFT) && desiredState.equals(RUNNING)) { BucketList bucketList = buckets.getBuckets(experimentID, false ); validator.validateExperimentBuckets(bucketList.getBuckets()); } } } }
ExperimentsImpl implements Experiments { @Override public void checkStateTransition(Experiment.ID experimentID, Experiment.State currentState, Experiment.State desiredState) { if (desiredState != null && !currentState.equals(desiredState)) { validator.validateStateTransition(currentState, desiredState); if (currentState.equals(DRAFT) && desiredState.equals(RUNNING)) { BucketList bucketList = buckets.getBuckets(experimentID, false ); validator.validateExperimentBuckets(bucketList.getBuckets()); } } } @Inject  ExperimentsImpl(@DatabaseRepository ExperimentRepository databaseRepository,
                           @CassandraRepository ExperimentRepository cassandraRepository, Experiments experiments,
                           Buckets buckets, Pages pages, Priorities priorities, ExperimentValidator validator,
                           RuleCache ruleCache, EventLog eventLog); }
ExperimentsImpl implements Experiments { @Override public void checkStateTransition(Experiment.ID experimentID, Experiment.State currentState, Experiment.State desiredState) { if (desiredState != null && !currentState.equals(desiredState)) { validator.validateStateTransition(currentState, desiredState); if (currentState.equals(DRAFT) && desiredState.equals(RUNNING)) { BucketList bucketList = buckets.getBuckets(experimentID, false ); validator.validateExperimentBuckets(bucketList.getBuckets()); } } } @Inject  ExperimentsImpl(@DatabaseRepository ExperimentRepository databaseRepository,
                           @CassandraRepository ExperimentRepository cassandraRepository, Experiments experiments,
                           Buckets buckets, Pages pages, Priorities priorities, ExperimentValidator validator,
                           RuleCache ruleCache, EventLog eventLog); @Override ExperimentList getExperiments(); @Override List<Application.Name> getApplications(); @Override Map<Application.Name, Set<String>> getTagsForApplications(Collection<Application.Name> applicationNames); @Override Experiment getExperiment(Experiment.ID id); @Override Experiment getExperiment(Application.Name appName, Experiment.Label label); @Override List<Experiment> getExperiments(Application.Name appName); @Override void createExperiment(NewExperiment newExperiment, UserInfo user); @Override void checkStateTransition(Experiment.ID experimentID, Experiment.State currentState,
                                     Experiment.State desiredState); @Override void checkForIllegalUpdate(Experiment experiment, Experiment updates); @Override void checkForIllegalTerminatedUpdate(Experiment experiment, Experiment updates); @Override void checkForIllegalPausedRunningUpdate(Experiment experiment, Experiment updates); @Override boolean buildUpdatedExperiment(Experiment experiment, Experiment updates, Experiment.Builder builder,
                                          List<ExperimentAuditInfo> changeList); @Override void updateSegmentationRule(Experiment experiment, UserInfo user); @Override Experiment updateExperiment(final Experiment.ID experimentID, final Experiment updates, final UserInfo user); @Override void updateExperimentState(final Experiment experiment, final Experiment.State state); }
ExperimentsImpl implements Experiments { @Override public void checkStateTransition(Experiment.ID experimentID, Experiment.State currentState, Experiment.State desiredState) { if (desiredState != null && !currentState.equals(desiredState)) { validator.validateStateTransition(currentState, desiredState); if (currentState.equals(DRAFT) && desiredState.equals(RUNNING)) { BucketList bucketList = buckets.getBuckets(experimentID, false ); validator.validateExperimentBuckets(bucketList.getBuckets()); } } } @Inject  ExperimentsImpl(@DatabaseRepository ExperimentRepository databaseRepository,
                           @CassandraRepository ExperimentRepository cassandraRepository, Experiments experiments,
                           Buckets buckets, Pages pages, Priorities priorities, ExperimentValidator validator,
                           RuleCache ruleCache, EventLog eventLog); @Override ExperimentList getExperiments(); @Override List<Application.Name> getApplications(); @Override Map<Application.Name, Set<String>> getTagsForApplications(Collection<Application.Name> applicationNames); @Override Experiment getExperiment(Experiment.ID id); @Override Experiment getExperiment(Application.Name appName, Experiment.Label label); @Override List<Experiment> getExperiments(Application.Name appName); @Override void createExperiment(NewExperiment newExperiment, UserInfo user); @Override void checkStateTransition(Experiment.ID experimentID, Experiment.State currentState,
                                     Experiment.State desiredState); @Override void checkForIllegalUpdate(Experiment experiment, Experiment updates); @Override void checkForIllegalTerminatedUpdate(Experiment experiment, Experiment updates); @Override void checkForIllegalPausedRunningUpdate(Experiment experiment, Experiment updates); @Override boolean buildUpdatedExperiment(Experiment experiment, Experiment updates, Experiment.Builder builder,
                                          List<ExperimentAuditInfo> changeList); @Override void updateSegmentationRule(Experiment experiment, UserInfo user); @Override Experiment updateExperiment(final Experiment.ID experimentID, final Experiment updates, final UserInfo user); @Override void updateExperimentState(final Experiment experiment, final Experiment.State state);  }