@Test public void testBuildUpdatedExperiment() { Experiment current = mock(Experiment.class); Experiment update = mock(Experiment.class); Experiment.Builder builder = mock(Experiment.Builder.class); List<Experiment.ExperimentAuditInfo> changeList = mock(List.class); boolean requiresUpdate = expImpl.buildUpdatedExperiment(current, update, builder, changeList); assertThat(requiresUpdate, is(false)); when(current.getState()).thenReturn(Experiment.State.DRAFT); when(update.getState()).thenReturn(Experiment.State.RUNNING); when(current.getDescription()).thenReturn("A"); when(update.getDescription()).thenReturn("B"); when(current.getSamplingPercent()).thenReturn(1.0); when(update.getSamplingPercent()).thenReturn(2.0); when(current.getStartTime()).thenReturn(new Date(1)); when(update.getStartTime()).thenReturn(new Date(2)); when(current.getEndTime()).thenReturn(new Date(100)); when(update.getEndTime()).thenReturn(new Date(200)); when(current.getIsPersonalizationEnabled()).thenReturn(false); when(update.getIsPersonalizationEnabled()).thenReturn(true); when(current.getModelName()).thenReturn("A"); when(update.getModelName()).thenReturn("B"); when(current.getModelVersion()).thenReturn("V1"); when(update.getModelVersion()).thenReturn("V2"); when(current.getIsRapidExperiment()).thenReturn(false); when(update.getIsRapidExperiment()).thenReturn(true); when(current.getUserCap()).thenReturn(1); when(update.getUserCap()).thenReturn(2); when(current.getRule()).thenReturn("Rule-1"); when(update.getRule()).thenReturn("Rule-2"); when(current.getLabel()).thenReturn(Experiment.Label.valueOf("Lable-1")); when(update.getLabel()).thenReturn(Experiment.Label.valueOf("Label-2")); when(current.getApplicationName()).thenReturn(Application.Name.valueOf("App1")); when(update.getApplicationName()).thenReturn(Application.Name.valueOf("App2")); requiresUpdate = expImpl.buildUpdatedExperiment(current, update, builder, changeList); assertThat(requiresUpdate, is(true)); verify(builder, times(1)).withState(Experiment.State.RUNNING); verify(builder, times(1)).withDescription("B"); verify(builder, times(1)).withSamplingPercent(2.0); verify(builder, times(1)).withStartTime(new Date(2)); verify(builder, times(1)).withEndTime(new Date(200)); verify(builder, times(1)).withIsPersonalizationEnabled(true); verify(builder, times(1)).withModelName("B"); verify(builder, times(1)).withModelVersion("V2"); verify(builder, times(1)).withIsRapidExperiment(true); verify(builder, times(1)).withUserCap(2); verify(builder, times(1)).withRule("Rule-2"); verify(builder, times(1)).withLabel(Experiment.Label.valueOf("Label-2")); verify(builder, times(1)).withApplicationName(Application.Name.valueOf("App2")); verify(changeList, times(11)).add(any(Experiment.ExperimentAuditInfo.class)); }
@Override public boolean buildUpdatedExperiment(Experiment experiment, Experiment updates, Experiment.Builder builder, List<ExperimentAuditInfo> changeList) { boolean requiresUpdate = false; ExperimentAuditInfo changeData; if (updates.getState() != null && !updates.getState().equals(experiment.getState())) { builder.withState(updates.getState()); requiresUpdate = true; changeData = new ExperimentAuditInfo("state", experiment.getState().toString(), updates.getState().toString()); changeList.add(changeData); } if (updates.getDescription() != null && !updates.getDescription().equals(experiment.getDescription())) { builder.withDescription(updates.getDescription()); requiresUpdate = true; changeData = new ExperimentAuditInfo("description", experiment.getDescription(), updates.getDescription()); changeList.add(changeData); } if (updates.getHypothesisIsCorrect() != null && !updates.getHypothesisIsCorrect().equals(experiment.getHypothesisIsCorrect())) { builder.withHypothesisIsCorrect(updates.getHypothesisIsCorrect()); requiresUpdate = true; changeData = new ExperimentAuditInfo("hypothesis_is_correct", experiment.getHypothesisIsCorrect(), updates.getHypothesisIsCorrect()); changeList.add(changeData); } if (updates.getResults() != null && !updates.getResults().equals(experiment.getResults())) { builder.withResults(updates.getResults()); requiresUpdate = true; changeData = new ExperimentAuditInfo("results", experiment.getResults(), updates.getResults()); changeList.add(changeData); } if (updates.getSamplingPercent() != null && !updates.getSamplingPercent().equals(experiment.getSamplingPercent())) { builder.withSamplingPercent(updates.getSamplingPercent()); requiresUpdate = true; changeData = new ExperimentAuditInfo("sampling_percent", experiment.getSamplingPercent().toString(), updates.getSamplingPercent().toString()); changeList.add(changeData); } if (updates.getStartTime() != null && !updates.getStartTime().equals(experiment.getStartTime())) { builder.withStartTime(updates.getStartTime()); requiresUpdate = true; changeData = new ExperimentAuditInfo("start_time", experiment.getStartTime().toString(), updates.getStartTime().toString()); changeList.add(changeData); } if (updates.getEndTime() != null && !updates.getEndTime().equals(experiment.getEndTime())) { builder.withEndTime(updates.getEndTime()); requiresUpdate = true; changeData = new ExperimentAuditInfo("end_time", experiment.getEndTime().toString(), updates.getEndTime().toString()); changeList.add(changeData); } if (updates.getIsPersonalizationEnabled() != null && !updates.getIsPersonalizationEnabled().equals(experiment.getIsPersonalizationEnabled())) { builder.withIsPersonalizationEnabled(updates.getIsPersonalizationEnabled()); requiresUpdate = true; changeData = new ExperimentAuditInfo("isPersonalizationEnabled", experiment.getIsPersonalizationEnabled().toString(), updates.getIsPersonalizationEnabled().toString()); changeList.add(changeData); } if (updates.getModelName() != null && !updates.getModelName().equals(experiment.getModelName())) { builder.withModelName(updates.getModelName()); requiresUpdate = true; changeData = new ExperimentAuditInfo("modelName", experiment.getModelName(), updates.getModelName()); changeList.add(changeData); } if (updates.getModelVersion() != null && !updates.getModelVersion().equals(experiment.getModelVersion())) { builder.withModelVersion(updates.getModelVersion()); requiresUpdate = true; changeData = new ExperimentAuditInfo("modelVersion", experiment.getModelVersion(), updates.getModelVersion()); changeList.add(changeData); } if (updates.getIsRapidExperiment() != null && !updates.getIsRapidExperiment().equals(experiment.getIsRapidExperiment())) { builder.withIsRapidExperiment(updates.getIsRapidExperiment()); requiresUpdate = true; changeData = new ExperimentAuditInfo("isRapidExperiment", experiment.getIsRapidExperiment().toString(), updates.getIsRapidExperiment().toString()); changeList.add(changeData); } if (updates.getUserCap() != null && !updates.getUserCap().equals(experiment.getUserCap())) { builder.withUserCap(updates.getUserCap()); requiresUpdate = true; changeData = new ExperimentAuditInfo("userCap", experiment.getUserCap().toString(), updates.getUserCap().toString()); changeList.add(changeData); } if (updates.getRule() != null && !updates.getRule().equals(experiment.getRule())) { builder.withRule(updates.getRule()); requiresUpdate = true; changeData = new ExperimentAuditInfo("rule", experiment.getRule(), updates.getRule()); changeList.add(changeData); } if (updates.getSourceURL() != null && !updates.getSourceURL().equals(experiment.getSourceURL())) { builder.withSourceURL(updates.getSourceURL()); requiresUpdate = true; changeData = new ExperimentAuditInfo("sourceURL", experiment.getSourceURL().toString(), updates.getSourceURL()); changeList.add(changeData); } if (updates.getExperimentType() != null && !updates.getExperimentType().equals(experiment.getExperimentType())) { builder.withExperimentType(updates.getExperimentType()); requiresUpdate = true; changeData = new ExperimentAuditInfo("experimentType", experiment.getExperimentType().toString(), updates.getExperimentType()); changeList.add(changeData); } if (updates.getTags() != null && !updates.getTags().equals(experiment.getTags())) { builder.withTags(updates.getTags()); requiresUpdate = true; Set<String> oldTags = experiment.getTags() == null ? Collections.EMPTY_SET : experiment.getTags(); changeData = new ExperimentAuditInfo("tags", oldTags.toString(), updates.getTags().toString()); changeList.add(changeData); } if (updates.getLabel() != null && !updates.getLabel().equals(experiment.getLabel())) { builder.withLabel(updates.getLabel()); requiresUpdate = true; } if (updates.getApplicationName() != null && !updates.getApplicationName().equals(experiment.getApplicationName())) { builder.withApplicationName(updates.getApplicationName()); requiresUpdate = true; } return requiresUpdate; }
ExperimentsImpl implements Experiments { @Override public boolean buildUpdatedExperiment(Experiment experiment, Experiment updates, Experiment.Builder builder, List<ExperimentAuditInfo> changeList) { boolean requiresUpdate = false; ExperimentAuditInfo changeData; if (updates.getState() != null && !updates.getState().equals(experiment.getState())) { builder.withState(updates.getState()); requiresUpdate = true; changeData = new ExperimentAuditInfo("state", experiment.getState().toString(), updates.getState().toString()); changeList.add(changeData); } if (updates.getDescription() != null && !updates.getDescription().equals(experiment.getDescription())) { builder.withDescription(updates.getDescription()); requiresUpdate = true; changeData = new ExperimentAuditInfo("description", experiment.getDescription(), updates.getDescription()); changeList.add(changeData); } if (updates.getHypothesisIsCorrect() != null && !updates.getHypothesisIsCorrect().equals(experiment.getHypothesisIsCorrect())) { builder.withHypothesisIsCorrect(updates.getHypothesisIsCorrect()); requiresUpdate = true; changeData = new ExperimentAuditInfo("hypothesis_is_correct", experiment.getHypothesisIsCorrect(), updates.getHypothesisIsCorrect()); changeList.add(changeData); } if (updates.getResults() != null && !updates.getResults().equals(experiment.getResults())) { builder.withResults(updates.getResults()); requiresUpdate = true; changeData = new ExperimentAuditInfo("results", experiment.getResults(), updates.getResults()); changeList.add(changeData); } if (updates.getSamplingPercent() != null && !updates.getSamplingPercent().equals(experiment.getSamplingPercent())) { builder.withSamplingPercent(updates.getSamplingPercent()); requiresUpdate = true; changeData = new ExperimentAuditInfo("sampling_percent", experiment.getSamplingPercent().toString(), updates.getSamplingPercent().toString()); changeList.add(changeData); } if (updates.getStartTime() != null && !updates.getStartTime().equals(experiment.getStartTime())) { builder.withStartTime(updates.getStartTime()); requiresUpdate = true; changeData = new ExperimentAuditInfo("start_time", experiment.getStartTime().toString(), updates.getStartTime().toString()); changeList.add(changeData); } if (updates.getEndTime() != null && !updates.getEndTime().equals(experiment.getEndTime())) { builder.withEndTime(updates.getEndTime()); requiresUpdate = true; changeData = new ExperimentAuditInfo("end_time", experiment.getEndTime().toString(), updates.getEndTime().toString()); changeList.add(changeData); } if (updates.getIsPersonalizationEnabled() != null && !updates.getIsPersonalizationEnabled().equals(experiment.getIsPersonalizationEnabled())) { builder.withIsPersonalizationEnabled(updates.getIsPersonalizationEnabled()); requiresUpdate = true; changeData = new ExperimentAuditInfo("isPersonalizationEnabled", experiment.getIsPersonalizationEnabled().toString(), updates.getIsPersonalizationEnabled().toString()); changeList.add(changeData); } if (updates.getModelName() != null && !updates.getModelName().equals(experiment.getModelName())) { builder.withModelName(updates.getModelName()); requiresUpdate = true; changeData = new ExperimentAuditInfo("modelName", experiment.getModelName(), updates.getModelName()); changeList.add(changeData); } if (updates.getModelVersion() != null && !updates.getModelVersion().equals(experiment.getModelVersion())) { builder.withModelVersion(updates.getModelVersion()); requiresUpdate = true; changeData = new ExperimentAuditInfo("modelVersion", experiment.getModelVersion(), updates.getModelVersion()); changeList.add(changeData); } if (updates.getIsRapidExperiment() != null && !updates.getIsRapidExperiment().equals(experiment.getIsRapidExperiment())) { builder.withIsRapidExperiment(updates.getIsRapidExperiment()); requiresUpdate = true; changeData = new ExperimentAuditInfo("isRapidExperiment", experiment.getIsRapidExperiment().toString(), updates.getIsRapidExperiment().toString()); changeList.add(changeData); } if (updates.getUserCap() != null && !updates.getUserCap().equals(experiment.getUserCap())) { builder.withUserCap(updates.getUserCap()); requiresUpdate = true; changeData = new ExperimentAuditInfo("userCap", experiment.getUserCap().toString(), updates.getUserCap().toString()); changeList.add(changeData); } if (updates.getRule() != null && !updates.getRule().equals(experiment.getRule())) { builder.withRule(updates.getRule()); requiresUpdate = true; changeData = new ExperimentAuditInfo("rule", experiment.getRule(), updates.getRule()); changeList.add(changeData); } if (updates.getSourceURL() != null && !updates.getSourceURL().equals(experiment.getSourceURL())) { builder.withSourceURL(updates.getSourceURL()); requiresUpdate = true; changeData = new ExperimentAuditInfo("sourceURL", experiment.getSourceURL().toString(), updates.getSourceURL()); changeList.add(changeData); } if (updates.getExperimentType() != null && !updates.getExperimentType().equals(experiment.getExperimentType())) { builder.withExperimentType(updates.getExperimentType()); requiresUpdate = true; changeData = new ExperimentAuditInfo("experimentType", experiment.getExperimentType().toString(), updates.getExperimentType()); changeList.add(changeData); } if (updates.getTags() != null && !updates.getTags().equals(experiment.getTags())) { builder.withTags(updates.getTags()); requiresUpdate = true; Set<String> oldTags = experiment.getTags() == null ? Collections.EMPTY_SET : experiment.getTags(); changeData = new ExperimentAuditInfo("tags", oldTags.toString(), updates.getTags().toString()); changeList.add(changeData); } if (updates.getLabel() != null && !updates.getLabel().equals(experiment.getLabel())) { builder.withLabel(updates.getLabel()); requiresUpdate = true; } if (updates.getApplicationName() != null && !updates.getApplicationName().equals(experiment.getApplicationName())) { builder.withApplicationName(updates.getApplicationName()); requiresUpdate = true; } return requiresUpdate; } }
ExperimentsImpl implements Experiments { @Override public boolean buildUpdatedExperiment(Experiment experiment, Experiment updates, Experiment.Builder builder, List<ExperimentAuditInfo> changeList) { boolean requiresUpdate = false; ExperimentAuditInfo changeData; if (updates.getState() != null && !updates.getState().equals(experiment.getState())) { builder.withState(updates.getState()); requiresUpdate = true; changeData = new ExperimentAuditInfo("state", experiment.getState().toString(), updates.getState().toString()); changeList.add(changeData); } if (updates.getDescription() != null && !updates.getDescription().equals(experiment.getDescription())) { builder.withDescription(updates.getDescription()); requiresUpdate = true; changeData = new ExperimentAuditInfo("description", experiment.getDescription(), updates.getDescription()); changeList.add(changeData); } if (updates.getHypothesisIsCorrect() != null && !updates.getHypothesisIsCorrect().equals(experiment.getHypothesisIsCorrect())) { builder.withHypothesisIsCorrect(updates.getHypothesisIsCorrect()); requiresUpdate = true; changeData = new ExperimentAuditInfo("hypothesis_is_correct", experiment.getHypothesisIsCorrect(), updates.getHypothesisIsCorrect()); changeList.add(changeData); } if (updates.getResults() != null && !updates.getResults().equals(experiment.getResults())) { builder.withResults(updates.getResults()); requiresUpdate = true; changeData = new ExperimentAuditInfo("results", experiment.getResults(), updates.getResults()); changeList.add(changeData); } if (updates.getSamplingPercent() != null && !updates.getSamplingPercent().equals(experiment.getSamplingPercent())) { builder.withSamplingPercent(updates.getSamplingPercent()); requiresUpdate = true; changeData = new ExperimentAuditInfo("sampling_percent", experiment.getSamplingPercent().toString(), updates.getSamplingPercent().toString()); changeList.add(changeData); } if (updates.getStartTime() != null && !updates.getStartTime().equals(experiment.getStartTime())) { builder.withStartTime(updates.getStartTime()); requiresUpdate = true; changeData = new ExperimentAuditInfo("start_time", experiment.getStartTime().toString(), updates.getStartTime().toString()); changeList.add(changeData); } if (updates.getEndTime() != null && !updates.getEndTime().equals(experiment.getEndTime())) { builder.withEndTime(updates.getEndTime()); requiresUpdate = true; changeData = new ExperimentAuditInfo("end_time", experiment.getEndTime().toString(), updates.getEndTime().toString()); changeList.add(changeData); } if (updates.getIsPersonalizationEnabled() != null && !updates.getIsPersonalizationEnabled().equals(experiment.getIsPersonalizationEnabled())) { builder.withIsPersonalizationEnabled(updates.getIsPersonalizationEnabled()); requiresUpdate = true; changeData = new ExperimentAuditInfo("isPersonalizationEnabled", experiment.getIsPersonalizationEnabled().toString(), updates.getIsPersonalizationEnabled().toString()); changeList.add(changeData); } if (updates.getModelName() != null && !updates.getModelName().equals(experiment.getModelName())) { builder.withModelName(updates.getModelName()); requiresUpdate = true; changeData = new ExperimentAuditInfo("modelName", experiment.getModelName(), updates.getModelName()); changeList.add(changeData); } if (updates.getModelVersion() != null && !updates.getModelVersion().equals(experiment.getModelVersion())) { builder.withModelVersion(updates.getModelVersion()); requiresUpdate = true; changeData = new ExperimentAuditInfo("modelVersion", experiment.getModelVersion(), updates.getModelVersion()); changeList.add(changeData); } if (updates.getIsRapidExperiment() != null && !updates.getIsRapidExperiment().equals(experiment.getIsRapidExperiment())) { builder.withIsRapidExperiment(updates.getIsRapidExperiment()); requiresUpdate = true; changeData = new ExperimentAuditInfo("isRapidExperiment", experiment.getIsRapidExperiment().toString(), updates.getIsRapidExperiment().toString()); changeList.add(changeData); } if (updates.getUserCap() != null && !updates.getUserCap().equals(experiment.getUserCap())) { builder.withUserCap(updates.getUserCap()); requiresUpdate = true; changeData = new ExperimentAuditInfo("userCap", experiment.getUserCap().toString(), updates.getUserCap().toString()); changeList.add(changeData); } if (updates.getRule() != null && !updates.getRule().equals(experiment.getRule())) { builder.withRule(updates.getRule()); requiresUpdate = true; changeData = new ExperimentAuditInfo("rule", experiment.getRule(), updates.getRule()); changeList.add(changeData); } if (updates.getSourceURL() != null && !updates.getSourceURL().equals(experiment.getSourceURL())) { builder.withSourceURL(updates.getSourceURL()); requiresUpdate = true; changeData = new ExperimentAuditInfo("sourceURL", experiment.getSourceURL().toString(), updates.getSourceURL()); changeList.add(changeData); } if (updates.getExperimentType() != null && !updates.getExperimentType().equals(experiment.getExperimentType())) { builder.withExperimentType(updates.getExperimentType()); requiresUpdate = true; changeData = new ExperimentAuditInfo("experimentType", experiment.getExperimentType().toString(), updates.getExperimentType()); changeList.add(changeData); } if (updates.getTags() != null && !updates.getTags().equals(experiment.getTags())) { builder.withTags(updates.getTags()); requiresUpdate = true; Set<String> oldTags = experiment.getTags() == null ? Collections.EMPTY_SET : experiment.getTags(); changeData = new ExperimentAuditInfo("tags", oldTags.toString(), updates.getTags().toString()); changeList.add(changeData); } if (updates.getLabel() != null && !updates.getLabel().equals(experiment.getLabel())) { builder.withLabel(updates.getLabel()); requiresUpdate = true; } if (updates.getApplicationName() != null && !updates.getApplicationName().equals(experiment.getApplicationName())) { builder.withApplicationName(updates.getApplicationName()); requiresUpdate = true; } return requiresUpdate; } @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 boolean buildUpdatedExperiment(Experiment experiment, Experiment updates, Experiment.Builder builder, List<ExperimentAuditInfo> changeList) { boolean requiresUpdate = false; ExperimentAuditInfo changeData; if (updates.getState() != null && !updates.getState().equals(experiment.getState())) { builder.withState(updates.getState()); requiresUpdate = true; changeData = new ExperimentAuditInfo("state", experiment.getState().toString(), updates.getState().toString()); changeList.add(changeData); } if (updates.getDescription() != null && !updates.getDescription().equals(experiment.getDescription())) { builder.withDescription(updates.getDescription()); requiresUpdate = true; changeData = new ExperimentAuditInfo("description", experiment.getDescription(), updates.getDescription()); changeList.add(changeData); } if (updates.getHypothesisIsCorrect() != null && !updates.getHypothesisIsCorrect().equals(experiment.getHypothesisIsCorrect())) { builder.withHypothesisIsCorrect(updates.getHypothesisIsCorrect()); requiresUpdate = true; changeData = new ExperimentAuditInfo("hypothesis_is_correct", experiment.getHypothesisIsCorrect(), updates.getHypothesisIsCorrect()); changeList.add(changeData); } if (updates.getResults() != null && !updates.getResults().equals(experiment.getResults())) { builder.withResults(updates.getResults()); requiresUpdate = true; changeData = new ExperimentAuditInfo("results", experiment.getResults(), updates.getResults()); changeList.add(changeData); } if (updates.getSamplingPercent() != null && !updates.getSamplingPercent().equals(experiment.getSamplingPercent())) { builder.withSamplingPercent(updates.getSamplingPercent()); requiresUpdate = true; changeData = new ExperimentAuditInfo("sampling_percent", experiment.getSamplingPercent().toString(), updates.getSamplingPercent().toString()); changeList.add(changeData); } if (updates.getStartTime() != null && !updates.getStartTime().equals(experiment.getStartTime())) { builder.withStartTime(updates.getStartTime()); requiresUpdate = true; changeData = new ExperimentAuditInfo("start_time", experiment.getStartTime().toString(), updates.getStartTime().toString()); changeList.add(changeData); } if (updates.getEndTime() != null && !updates.getEndTime().equals(experiment.getEndTime())) { builder.withEndTime(updates.getEndTime()); requiresUpdate = true; changeData = new ExperimentAuditInfo("end_time", experiment.getEndTime().toString(), updates.getEndTime().toString()); changeList.add(changeData); } if (updates.getIsPersonalizationEnabled() != null && !updates.getIsPersonalizationEnabled().equals(experiment.getIsPersonalizationEnabled())) { builder.withIsPersonalizationEnabled(updates.getIsPersonalizationEnabled()); requiresUpdate = true; changeData = new ExperimentAuditInfo("isPersonalizationEnabled", experiment.getIsPersonalizationEnabled().toString(), updates.getIsPersonalizationEnabled().toString()); changeList.add(changeData); } if (updates.getModelName() != null && !updates.getModelName().equals(experiment.getModelName())) { builder.withModelName(updates.getModelName()); requiresUpdate = true; changeData = new ExperimentAuditInfo("modelName", experiment.getModelName(), updates.getModelName()); changeList.add(changeData); } if (updates.getModelVersion() != null && !updates.getModelVersion().equals(experiment.getModelVersion())) { builder.withModelVersion(updates.getModelVersion()); requiresUpdate = true; changeData = new ExperimentAuditInfo("modelVersion", experiment.getModelVersion(), updates.getModelVersion()); changeList.add(changeData); } if (updates.getIsRapidExperiment() != null && !updates.getIsRapidExperiment().equals(experiment.getIsRapidExperiment())) { builder.withIsRapidExperiment(updates.getIsRapidExperiment()); requiresUpdate = true; changeData = new ExperimentAuditInfo("isRapidExperiment", experiment.getIsRapidExperiment().toString(), updates.getIsRapidExperiment().toString()); changeList.add(changeData); } if (updates.getUserCap() != null && !updates.getUserCap().equals(experiment.getUserCap())) { builder.withUserCap(updates.getUserCap()); requiresUpdate = true; changeData = new ExperimentAuditInfo("userCap", experiment.getUserCap().toString(), updates.getUserCap().toString()); changeList.add(changeData); } if (updates.getRule() != null && !updates.getRule().equals(experiment.getRule())) { builder.withRule(updates.getRule()); requiresUpdate = true; changeData = new ExperimentAuditInfo("rule", experiment.getRule(), updates.getRule()); changeList.add(changeData); } if (updates.getSourceURL() != null && !updates.getSourceURL().equals(experiment.getSourceURL())) { builder.withSourceURL(updates.getSourceURL()); requiresUpdate = true; changeData = new ExperimentAuditInfo("sourceURL", experiment.getSourceURL().toString(), updates.getSourceURL()); changeList.add(changeData); } if (updates.getExperimentType() != null && !updates.getExperimentType().equals(experiment.getExperimentType())) { builder.withExperimentType(updates.getExperimentType()); requiresUpdate = true; changeData = new ExperimentAuditInfo("experimentType", experiment.getExperimentType().toString(), updates.getExperimentType()); changeList.add(changeData); } if (updates.getTags() != null && !updates.getTags().equals(experiment.getTags())) { builder.withTags(updates.getTags()); requiresUpdate = true; Set<String> oldTags = experiment.getTags() == null ? Collections.EMPTY_SET : experiment.getTags(); changeData = new ExperimentAuditInfo("tags", oldTags.toString(), updates.getTags().toString()); changeList.add(changeData); } if (updates.getLabel() != null && !updates.getLabel().equals(experiment.getLabel())) { builder.withLabel(updates.getLabel()); requiresUpdate = true; } if (updates.getApplicationName() != null && !updates.getApplicationName().equals(experiment.getApplicationName())) { builder.withApplicationName(updates.getApplicationName()); requiresUpdate = true; } return requiresUpdate; } @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 boolean buildUpdatedExperiment(Experiment experiment, Experiment updates, Experiment.Builder builder, List<ExperimentAuditInfo> changeList) { boolean requiresUpdate = false; ExperimentAuditInfo changeData; if (updates.getState() != null && !updates.getState().equals(experiment.getState())) { builder.withState(updates.getState()); requiresUpdate = true; changeData = new ExperimentAuditInfo("state", experiment.getState().toString(), updates.getState().toString()); changeList.add(changeData); } if (updates.getDescription() != null && !updates.getDescription().equals(experiment.getDescription())) { builder.withDescription(updates.getDescription()); requiresUpdate = true; changeData = new ExperimentAuditInfo("description", experiment.getDescription(), updates.getDescription()); changeList.add(changeData); } if (updates.getHypothesisIsCorrect() != null && !updates.getHypothesisIsCorrect().equals(experiment.getHypothesisIsCorrect())) { builder.withHypothesisIsCorrect(updates.getHypothesisIsCorrect()); requiresUpdate = true; changeData = new ExperimentAuditInfo("hypothesis_is_correct", experiment.getHypothesisIsCorrect(), updates.getHypothesisIsCorrect()); changeList.add(changeData); } if (updates.getResults() != null && !updates.getResults().equals(experiment.getResults())) { builder.withResults(updates.getResults()); requiresUpdate = true; changeData = new ExperimentAuditInfo("results", experiment.getResults(), updates.getResults()); changeList.add(changeData); } if (updates.getSamplingPercent() != null && !updates.getSamplingPercent().equals(experiment.getSamplingPercent())) { builder.withSamplingPercent(updates.getSamplingPercent()); requiresUpdate = true; changeData = new ExperimentAuditInfo("sampling_percent", experiment.getSamplingPercent().toString(), updates.getSamplingPercent().toString()); changeList.add(changeData); } if (updates.getStartTime() != null && !updates.getStartTime().equals(experiment.getStartTime())) { builder.withStartTime(updates.getStartTime()); requiresUpdate = true; changeData = new ExperimentAuditInfo("start_time", experiment.getStartTime().toString(), updates.getStartTime().toString()); changeList.add(changeData); } if (updates.getEndTime() != null && !updates.getEndTime().equals(experiment.getEndTime())) { builder.withEndTime(updates.getEndTime()); requiresUpdate = true; changeData = new ExperimentAuditInfo("end_time", experiment.getEndTime().toString(), updates.getEndTime().toString()); changeList.add(changeData); } if (updates.getIsPersonalizationEnabled() != null && !updates.getIsPersonalizationEnabled().equals(experiment.getIsPersonalizationEnabled())) { builder.withIsPersonalizationEnabled(updates.getIsPersonalizationEnabled()); requiresUpdate = true; changeData = new ExperimentAuditInfo("isPersonalizationEnabled", experiment.getIsPersonalizationEnabled().toString(), updates.getIsPersonalizationEnabled().toString()); changeList.add(changeData); } if (updates.getModelName() != null && !updates.getModelName().equals(experiment.getModelName())) { builder.withModelName(updates.getModelName()); requiresUpdate = true; changeData = new ExperimentAuditInfo("modelName", experiment.getModelName(), updates.getModelName()); changeList.add(changeData); } if (updates.getModelVersion() != null && !updates.getModelVersion().equals(experiment.getModelVersion())) { builder.withModelVersion(updates.getModelVersion()); requiresUpdate = true; changeData = new ExperimentAuditInfo("modelVersion", experiment.getModelVersion(), updates.getModelVersion()); changeList.add(changeData); } if (updates.getIsRapidExperiment() != null && !updates.getIsRapidExperiment().equals(experiment.getIsRapidExperiment())) { builder.withIsRapidExperiment(updates.getIsRapidExperiment()); requiresUpdate = true; changeData = new ExperimentAuditInfo("isRapidExperiment", experiment.getIsRapidExperiment().toString(), updates.getIsRapidExperiment().toString()); changeList.add(changeData); } if (updates.getUserCap() != null && !updates.getUserCap().equals(experiment.getUserCap())) { builder.withUserCap(updates.getUserCap()); requiresUpdate = true; changeData = new ExperimentAuditInfo("userCap", experiment.getUserCap().toString(), updates.getUserCap().toString()); changeList.add(changeData); } if (updates.getRule() != null && !updates.getRule().equals(experiment.getRule())) { builder.withRule(updates.getRule()); requiresUpdate = true; changeData = new ExperimentAuditInfo("rule", experiment.getRule(), updates.getRule()); changeList.add(changeData); } if (updates.getSourceURL() != null && !updates.getSourceURL().equals(experiment.getSourceURL())) { builder.withSourceURL(updates.getSourceURL()); requiresUpdate = true; changeData = new ExperimentAuditInfo("sourceURL", experiment.getSourceURL().toString(), updates.getSourceURL()); changeList.add(changeData); } if (updates.getExperimentType() != null && !updates.getExperimentType().equals(experiment.getExperimentType())) { builder.withExperimentType(updates.getExperimentType()); requiresUpdate = true; changeData = new ExperimentAuditInfo("experimentType", experiment.getExperimentType().toString(), updates.getExperimentType()); changeList.add(changeData); } if (updates.getTags() != null && !updates.getTags().equals(experiment.getTags())) { builder.withTags(updates.getTags()); requiresUpdate = true; Set<String> oldTags = experiment.getTags() == null ? Collections.EMPTY_SET : experiment.getTags(); changeData = new ExperimentAuditInfo("tags", oldTags.toString(), updates.getTags().toString()); changeList.add(changeData); } if (updates.getLabel() != null && !updates.getLabel().equals(experiment.getLabel())) { builder.withLabel(updates.getLabel()); requiresUpdate = true; } if (updates.getApplicationName() != null && !updates.getApplicationName().equals(experiment.getApplicationName())) { builder.withApplicationName(updates.getApplicationName()); requiresUpdate = true; } return requiresUpdate; } @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);  }