PreparationEventUtil { public void performUpdateEvent(String datasetId) { LOGGER.info("Performing update event for dataset {}", datasetId); cleanTransformationCache(datasetId); cleanTransformationMetadataCache(datasetId); updatesFromDataSetMetadata(datasetId); }  void performUpdateEvent(String datasetId);  }
@Test public void shouldRemoveStepRowMetadata() { final DataSetMetadata metadata = new DataSetMetadata(); metadata.setId("ds-1234"); final Step step1 = new Step(); step1.setId(UUID.randomUUID().toString()); step1.setRowMetadata("srmd-1"); final Step step2 = new Step(); step2.setId(UUID.randomUUID().toString()); step2.setRowMetadata("srmd-2"); step2.setParent(step1.id()); final Step step3 = new Step(); step3.setId(UUID.randomUUID().toString()); step3.setRowMetadata(null); step3.setParent(step2.id()); final PersistentPreparation preparation = new PersistentPreparation(); preparation.setHeadId(step3.id()); when(preparationUtils.listSteps(eq(preparation.getHeadId()), eq(preparationRepository))) .thenReturn(Arrays.asList(Step.ROOT_STEP, step1, step2, step3)); when(preparationRepository.list(eq(PersistentPreparation.class), eq(TqlBuilder.eq("dataSetId", "ds-1234")))) .thenReturn(Stream.of(preparation), Stream.of(preparation)); when(preparationRepository.get(eq(step1.id()), eq(Step.class))).thenReturn(step1); when(preparationRepository.get(eq(step2.id()), eq(Step.class))).thenReturn(step2); when(datasetClient.getDataSetMetadata(any())).thenReturn(metadata); preparationEventUtil.performUpdateEvent(metadata.getId()); verify(cacheEventProcessingUtil, times(2)).processCleanCacheEvent(any(ContentCacheKey.class), any()); verify(preparationRepository, times(1)).add(any(Preparation.class)); verify(preparationRepository, times(1)).remove(eq(StepRowMetadata.class), eq(TqlBuilder.in("id", "srmd-1", "srmd-2"))); verify(securityProxy, times(2)).asTechnicalUser(); verify(securityProxy, times(1)).asTechnicalUserForDataSet(); verify(securityProxy, times(3)).releaseIdentity(); }
@Test public void shouldUpdateDataSetName() { final DataSetMetadata metadata = new DataSetMetadata(); metadata.setId("ds-1234"); metadata.setName("My updated name"); final PersistentPreparation preparation = mock(PersistentPreparation.class); when(preparationRepository.list(eq(PersistentPreparation.class), eq(TqlBuilder.eq("dataSetId", "ds-1234")))) .thenReturn(Stream.of(preparation), Stream.of(preparation)); when(datasetClient.getDataSetMetadata(eq("ds-1234"))).thenReturn(metadata); preparationEventUtil.performUpdateEvent(metadata.getId()); verify(preparation, times(1)).setDataSetName(eq("My updated name")); }