/** * Tests that the {@link DataSaverProcessor} will not save data type if type is not registered * with a processor. */ @Test public void testSimpleSaverExclusive() { List<Class<? extends DefaultData>> includedClasses = new ArrayList<>(); includedClasses.add(InvocationSequenceData.class); DataSaverProcessor dataSaverProcessor = new DataSaverProcessor(includedClasses, true); dataSaverProcessor.setStorageWriter(storageWriter); TimerData timerData = new TimerData(); assertThat(dataSaverProcessor.canBeProcessed(timerData), is(false)); Collection<Future<Void>> futures = dataSaverProcessor.process(timerData); assertThat(futures, is(empty())); verifyZeroInteractions(storageWriter); }
/** * {@inheritDoc} */ @Override protected Collection<Future<Void>> processData(DefaultData defaultData) { // if I am writing the InvocationAwareData and invocations are not saved // make sure we don't save the invocation affiliation if ((defaultData instanceof InvocationAwareData) && !writeInvocationAffiliation) { Map<String, Boolean> kryoPreferences = new HashMap<>(1); kryoPreferences.put(KryoSerializationPreferences.WRITE_INVOCATION_AFFILIATION_DATA, Boolean.FALSE); Future<Void> future = getStorageWriter().write(defaultData, kryoPreferences); if (null != future) { return Collections.singleton(future); } } else { Future<Void> future = getStorageWriter().write(defaultData); if (null != future) { return Collections.singleton(future); } } return Collections.emptyList(); }
/** * Init. */ @BeforeClass public void createStorageData() { storageData = getStorageData(); createdInvocations = new ArrayList<>(); List<Class<? extends DefaultData>> saverClasses = new ArrayList<>(); saverClasses.add(InvocationSequenceData.class); dataSaverProcessor = new DataSaverProcessor(saverClasses, true); }
normalProcessors.add(new DataSaverProcessor(saveClassesList, writeInvocationAffiliation));
/** * Tests that the {@link DataSaverProcessor} will save data type if type is not registered with * a processor. */ @Test public void testSimpleSaverInclusive() { List<Class<? extends DefaultData>> includedClasses = new ArrayList<>(); includedClasses.add(InvocationSequenceData.class); DataSaverProcessor dataSaverProcessor = new DataSaverProcessor(includedClasses, true); dataSaverProcessor.setStorageWriter(storageWriter); InvocationSequenceData invocation = new InvocationSequenceData(); assertThat(dataSaverProcessor.canBeProcessed(invocation), is(true)); Collection<Future<Void>> futures = dataSaverProcessor.process(invocation); assertThat(futures, hasSize(1)); verify(storageWriter, times(1)).write(invocation); }
Collections.addAll(classesToSave, InvocationSequenceData.class, HttpTimerData.class, ExceptionSensorData.class, MemoryInformationData.class, CpuInformationData.class, ClassLoadingInformationData.class, ThreadInformationData.class, SystemInformationData.class); DataSaverProcessor dataSaverProcessor = new DataSaverProcessor(classesToSave, true); normalProcessors.add(dataSaverProcessor);