@Test public void testCheckForIllegalUpdate() { Experiment testExp = Experiment.withID(experimentID) .withApplicationName(testApp) .withLabel(testLabel) .withSamplingPercent(samplingPercent) .withStartTime(startTime) .withEndTime(endTime).build(); Experiment updateExp = Experiment.withID(experimentID) .withApplicationName(testApp) .withLabel(testLabel) .withSamplingPercent(samplingPercent) .withStartTime(startTime) .withEndTime(endTime).build(); updateExp.setID(Experiment.ID.newInstance()); try { expImpl.checkForIllegalUpdate(testExp, updateExp); fail("Expected IllegalArgumentException."); } catch (Exception e) { assertEquals(e.getClass(), IllegalArgumentException.class); } updateExp.setID(experimentID); Date tempCreationTime = updateExp.getCreationTime(); updateExp.setCreationTime(new Date()); try { expImpl.checkForIllegalUpdate(testExp, updateExp); fail("Expected IllegalArgumentException."); } catch (Exception e) { assertEquals(e.getClass(), IllegalArgumentException.class); } updateExp.setCreationTime(tempCreationTime); updateExp.setModificationTime(new Date()); try { expImpl.checkForIllegalUpdate(testExp, updateExp); fail("Expected IllegalArgumentException."); } catch (Exception e) { assertEquals(e.getClass(), IllegalArgumentException.class); } }
@Override public void checkForIllegalUpdate(Experiment experiment, Experiment updates) { if (updates.getID() != null && !updates.getID().equals(experiment.getID())) { throw new IllegalArgumentException("Invalid experimentID \"" + updates.getID() + "\" " + "Cannot change experiment ID"); } if (updates.getCreationTime() != null && !updates.getCreationTime().equals(experiment.getCreationTime())) { throw new IllegalArgumentException("Invalid creationTime \"" + updates.getCreationTime() + "\" " + "Experiment creation time cannot be modified"); } if (updates.getModificationTime() != null && !updates.getModificationTime().equals(experiment.getModificationTime())) { throw new IllegalArgumentException("Invalid modificationTime \"" + updates.getModificationTime() + "\" " + "Experiment modification time cannot be modified"); } }
ExperimentsImpl implements Experiments { @Override public void checkForIllegalUpdate(Experiment experiment, Experiment updates) { if (updates.getID() != null && !updates.getID().equals(experiment.getID())) { throw new IllegalArgumentException("Invalid experimentID \"" + updates.getID() + "\" " + "Cannot change experiment ID"); } if (updates.getCreationTime() != null && !updates.getCreationTime().equals(experiment.getCreationTime())) { throw new IllegalArgumentException("Invalid creationTime \"" + updates.getCreationTime() + "\" " + "Experiment creation time cannot be modified"); } if (updates.getModificationTime() != null && !updates.getModificationTime().equals(experiment.getModificationTime())) { throw new IllegalArgumentException("Invalid modificationTime \"" + updates.getModificationTime() + "\" " + "Experiment modification time cannot be modified"); } } }
ExperimentsImpl implements Experiments { @Override public void checkForIllegalUpdate(Experiment experiment, Experiment updates) { if (updates.getID() != null && !updates.getID().equals(experiment.getID())) { throw new IllegalArgumentException("Invalid experimentID \"" + updates.getID() + "\" " + "Cannot change experiment ID"); } if (updates.getCreationTime() != null && !updates.getCreationTime().equals(experiment.getCreationTime())) { throw new IllegalArgumentException("Invalid creationTime \"" + updates.getCreationTime() + "\" " + "Experiment creation time cannot be modified"); } if (updates.getModificationTime() != null && !updates.getModificationTime().equals(experiment.getModificationTime())) { throw new IllegalArgumentException("Invalid modificationTime \"" + updates.getModificationTime() + "\" " + "Experiment modification time cannot be modified"); } } @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 checkForIllegalUpdate(Experiment experiment, Experiment updates) { if (updates.getID() != null && !updates.getID().equals(experiment.getID())) { throw new IllegalArgumentException("Invalid experimentID \"" + updates.getID() + "\" " + "Cannot change experiment ID"); } if (updates.getCreationTime() != null && !updates.getCreationTime().equals(experiment.getCreationTime())) { throw new IllegalArgumentException("Invalid creationTime \"" + updates.getCreationTime() + "\" " + "Experiment creation time cannot be modified"); } if (updates.getModificationTime() != null && !updates.getModificationTime().equals(experiment.getModificationTime())) { throw new IllegalArgumentException("Invalid modificationTime \"" + updates.getModificationTime() + "\" " + "Experiment modification time cannot be modified"); } } @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 checkForIllegalUpdate(Experiment experiment, Experiment updates) { if (updates.getID() != null && !updates.getID().equals(experiment.getID())) { throw new IllegalArgumentException("Invalid experimentID \"" + updates.getID() + "\" " + "Cannot change experiment ID"); } if (updates.getCreationTime() != null && !updates.getCreationTime().equals(experiment.getCreationTime())) { throw new IllegalArgumentException("Invalid creationTime \"" + updates.getCreationTime() + "\" " + "Experiment creation time cannot be modified"); } if (updates.getModificationTime() != null && !updates.getModificationTime().equals(experiment.getModificationTime())) { throw new IllegalArgumentException("Invalid modificationTime \"" + updates.getModificationTime() + "\" " + "Experiment modification time cannot be modified"); } } @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);  }