@Test public void testUpdateTags() { Application.Name appName = Application.Name.valueOf("AppName"); Set<String> exp1 = new TreeSet<>(Arrays.asList("tag1", "tag3")); Set<String> exp2 = new TreeSet<>(Arrays.asList("tag4")); ExperimentTagsByApplication exp2Tags = ExperimentTagsByApplication.builder() .tags(exp2).appName(appName.toString()).build(); ExperimentTagsByApplication exp1Tags = ExperimentTagsByApplication.builder() .tags(exp1).appName(appName.toString()).build(); List<ExperimentTagsByApplication> dbResultList = Arrays.asList(exp1Tags, exp2Tags); Result<ExperimentTagsByApplication> dbResult = mock(Result.class); when(mockExperimentAccessor.getAllTags(appName.toString())).thenReturn(dbResult); when(dbResult.all()).thenReturn(dbResultList); repository.updateExperimentTags(appName, experimentID1, exp1); repository.updateExperimentTags(appName, experimentID2, exp2); verify(mockExperimentTagAccessor).insert(appName.toString(), experimentID1.getRawID(), new TreeSet<>(Arrays.asList("tag1", "tag3"))); verify(mockExperimentTagAccessor).insert(appName.toString(), experimentID2.getRawID(), new TreeSet<>(Arrays.asList("tag4"))); }
public Statement updateExperimentTags(Application.Name applicationName, Experiment.ID expId, Set<String> tags) { if (tags == null) { tags = Collections.EMPTY_SET; } return experimentTagAccessor.insert(applicationName.toString(), expId.getRawID(), tags); }
CassandraExperimentRepository implements ExperimentRepository { public Statement updateExperimentTags(Application.Name applicationName, Experiment.ID expId, Set<String> tags) { if (tags == null) { tags = Collections.EMPTY_SET; } return experimentTagAccessor.insert(applicationName.toString(), expId.getRawID(), tags); } }
CassandraExperimentRepository implements ExperimentRepository { public Statement updateExperimentTags(Application.Name applicationName, Experiment.ID expId, Set<String> tags) { if (tags == null) { tags = Collections.EMPTY_SET; } return experimentTagAccessor.insert(applicationName.toString(), expId.getRawID(), tags); } @Inject  CassandraExperimentRepository(CassandraDriver driver,
                                         ExperimentAccessor experimentAccessor,
                                         ExperimentLabelIndexAccessor experimentLabelIndexAccessor,
                                         BucketAccessor bucketAccessor,
                                         ApplicationListAccessor applicationListAccessor,
                                         BucketAuditLogAccessor bucketAuditLogAccessor,
                                         ExperimentAuditLogAccessor experimentAuditLogAccessor,
                                         StateExperimentIndexAccessor stateExperimentIndexAccessor,
                                         ExperimentValidator validator,
                                         ExperimentTagAccessor experimentTagAccessor,
                                         PrioritiesAccessor prioritiesAccessor); }
CassandraExperimentRepository implements ExperimentRepository { public Statement updateExperimentTags(Application.Name applicationName, Experiment.ID expId, Set<String> tags) { if (tags == null) { tags = Collections.EMPTY_SET; } return experimentTagAccessor.insert(applicationName.toString(), expId.getRawID(), tags); } @Inject  CassandraExperimentRepository(CassandraDriver driver,
                                         ExperimentAccessor experimentAccessor,
                                         ExperimentLabelIndexAccessor experimentLabelIndexAccessor,
                                         BucketAccessor bucketAccessor,
                                         ApplicationListAccessor applicationListAccessor,
                                         BucketAuditLogAccessor bucketAuditLogAccessor,
                                         ExperimentAuditLogAccessor experimentAuditLogAccessor,
                                         StateExperimentIndexAccessor stateExperimentIndexAccessor,
                                         ExperimentValidator validator,
                                         ExperimentTagAccessor experimentTagAccessor,
                                         PrioritiesAccessor prioritiesAccessor); ExperimentAccessor getExperimentAccessor(); void setExperimentAccessor(ExperimentAccessor experimentAccessor); ExperimentLabelIndexAccessor getExperimentLabelIndexAccessor(); void setExperimentLabelIndexAccessor(
            ExperimentLabelIndexAccessor experimentLabelIndexAccessor); BucketAccessor getBucketAccessor(); void setBucketAccessor(BucketAccessor bucketAccessor); ApplicationListAccessor getApplicationListAccessor(); void setApplicationListAccessor(
            ApplicationListAccessor applicationListAccessor); StateExperimentIndexAccessor getStateExperimentIndexAccessor(); void setStateExperimentIndexAccessor(
            StateExperimentIndexAccessor stateExperimentIndexAccessor); BucketAuditLogAccessor getBucketAuditLogAccessor(); void setBucketAuditLogAccessor(
            BucketAuditLogAccessor bucketAuditLogAccessor); ExperimentAuditLogAccessor getExperimentAuditLogAccessor(); void setExperimentAuditLogAccessor(
            ExperimentAuditLogAccessor experimentAuditLogAccessor); @Override Experiment getExperiment(Experiment.ID experimentID); @Override Map<Application.Name, List<Experiment>> getExperimentsForApps(Collection<Application.Name> appNames); @Override Experiment getExperiment(Application.Name appName,
                                    Experiment.Label experimentLabel); @Override Experiment.ID createExperiment(NewExperiment newExperiment); Statement updateExperimentTags(Application.Name applicationName, Experiment.ID expId, Set<String> tags); @Override void createIndicesForNewExperiment(NewExperiment newExperiment); @Override Map<Experiment.ID, BucketList> getBucketList(Collection<Experiment.ID> experimentIds); @Override BucketList getBucketList(Experiment.ID experimentID); @Override Experiment updateExperiment(Experiment experiment); @Override Experiment updateExperimentState(Experiment experiment, State state); @Override List<Experiment.ID> getExperiments(); @Override List<Experiment> getExperiments(Application.Name appName); @Override void deleteExperiment(NewExperiment newExperiment); @Override ExperimentList getExperiments(Collection<Experiment.ID> experimentIDs); @Override Map<Experiment.ID, Experiment> getExperimentsMap(Collection<Experiment.ID> experimentIds); @Override Table<Experiment.ID, Experiment.Label, Experiment> getExperimentList(Application.Name appName); @Override List<Application.Name> getApplicationsList(); @Override Bucket getBucket(Experiment.ID experimentID, Bucket.Label bucketLabel); @Override void createBucket(Bucket newBucket); @Override Bucket updateBucket(Bucket bucket); CassandraDriver getDriver(); void setDriver(CassandraDriver driver); @Override Bucket updateBucketAllocationPercentage(Bucket bucket, Double desiredAllocationPercentage); @Override Bucket updateBucketState(Bucket bucket, Bucket.State desiredState); @Override BucketList updateBucketBatch(Experiment.ID experimentID,
                                        BucketList bucketList); @Override void deleteBucket(Experiment.ID experimentID, Bucket.Label bucketLabel); @Override void logBucketChanges(Experiment.ID experimentID, Bucket.Label bucketLabel,
                                 List<BucketAuditInfo> changeList); @Override void logExperimentChanges(Experiment.ID experimentID, List<ExperimentAuditInfo> changeList); @Override BucketList getBuckets(Experiment.ID experimentID, boolean checkExperiment); @Override void updateStateIndex(Experiment experiment); @Override Statement createApplication(Application.Name applicationName); @Override Map<Application.Name, Set<String>> getTagListForApplications(Collection<Application.Name> applicationNames); }
CassandraExperimentRepository implements ExperimentRepository { public Statement updateExperimentTags(Application.Name applicationName, Experiment.ID expId, Set<String> tags) { if (tags == null) { tags = Collections.EMPTY_SET; } return experimentTagAccessor.insert(applicationName.toString(), expId.getRawID(), tags); } @Inject  CassandraExperimentRepository(CassandraDriver driver,
                                         ExperimentAccessor experimentAccessor,
                                         ExperimentLabelIndexAccessor experimentLabelIndexAccessor,
                                         BucketAccessor bucketAccessor,
                                         ApplicationListAccessor applicationListAccessor,
                                         BucketAuditLogAccessor bucketAuditLogAccessor,
                                         ExperimentAuditLogAccessor experimentAuditLogAccessor,
                                         StateExperimentIndexAccessor stateExperimentIndexAccessor,
                                         ExperimentValidator validator,
                                         ExperimentTagAccessor experimentTagAccessor,
                                         PrioritiesAccessor prioritiesAccessor); ExperimentAccessor getExperimentAccessor(); void setExperimentAccessor(ExperimentAccessor experimentAccessor); ExperimentLabelIndexAccessor getExperimentLabelIndexAccessor(); void setExperimentLabelIndexAccessor(
            ExperimentLabelIndexAccessor experimentLabelIndexAccessor); BucketAccessor getBucketAccessor(); void setBucketAccessor(BucketAccessor bucketAccessor); ApplicationListAccessor getApplicationListAccessor(); void setApplicationListAccessor(
            ApplicationListAccessor applicationListAccessor); StateExperimentIndexAccessor getStateExperimentIndexAccessor(); void setStateExperimentIndexAccessor(
            StateExperimentIndexAccessor stateExperimentIndexAccessor); BucketAuditLogAccessor getBucketAuditLogAccessor(); void setBucketAuditLogAccessor(
            BucketAuditLogAccessor bucketAuditLogAccessor); ExperimentAuditLogAccessor getExperimentAuditLogAccessor(); void setExperimentAuditLogAccessor(
            ExperimentAuditLogAccessor experimentAuditLogAccessor); @Override Experiment getExperiment(Experiment.ID experimentID); @Override Map<Application.Name, List<Experiment>> getExperimentsForApps(Collection<Application.Name> appNames); @Override Experiment getExperiment(Application.Name appName,
                                    Experiment.Label experimentLabel); @Override Experiment.ID createExperiment(NewExperiment newExperiment); Statement updateExperimentTags(Application.Name applicationName, Experiment.ID expId, Set<String> tags); @Override void createIndicesForNewExperiment(NewExperiment newExperiment); @Override Map<Experiment.ID, BucketList> getBucketList(Collection<Experiment.ID> experimentIds); @Override BucketList getBucketList(Experiment.ID experimentID); @Override Experiment updateExperiment(Experiment experiment); @Override Experiment updateExperimentState(Experiment experiment, State state); @Override List<Experiment.ID> getExperiments(); @Override List<Experiment> getExperiments(Application.Name appName); @Override void deleteExperiment(NewExperiment newExperiment); @Override ExperimentList getExperiments(Collection<Experiment.ID> experimentIDs); @Override Map<Experiment.ID, Experiment> getExperimentsMap(Collection<Experiment.ID> experimentIds); @Override Table<Experiment.ID, Experiment.Label, Experiment> getExperimentList(Application.Name appName); @Override List<Application.Name> getApplicationsList(); @Override Bucket getBucket(Experiment.ID experimentID, Bucket.Label bucketLabel); @Override void createBucket(Bucket newBucket); @Override Bucket updateBucket(Bucket bucket); CassandraDriver getDriver(); void setDriver(CassandraDriver driver); @Override Bucket updateBucketAllocationPercentage(Bucket bucket, Double desiredAllocationPercentage); @Override Bucket updateBucketState(Bucket bucket, Bucket.State desiredState); @Override BucketList updateBucketBatch(Experiment.ID experimentID,
                                        BucketList bucketList); @Override void deleteBucket(Experiment.ID experimentID, Bucket.Label bucketLabel); @Override void logBucketChanges(Experiment.ID experimentID, Bucket.Label bucketLabel,
                                 List<BucketAuditInfo> changeList); @Override void logExperimentChanges(Experiment.ID experimentID, List<ExperimentAuditInfo> changeList); @Override BucketList getBuckets(Experiment.ID experimentID, boolean checkExperiment); @Override void updateStateIndex(Experiment experiment); @Override Statement createApplication(Application.Name applicationName); @Override Map<Application.Name, Set<String>> getTagListForApplications(Collection<Application.Name> applicationNames);  }