use of org.iobserve.service.privacy.violation.data.ProbeManagementData in project iobserve-analysis by research-iobserve.
the class ModelProbeControllerTest method testEmptyWarningList.
@Test
public void testEmptyWarningList() {
final WarningModel warnings = new WarningModel();
warnings.setWarningEdges(null);
final List<WarningModel> input1 = new LinkedList<>();
input1.add(warnings);
final List<ProbeManagementData> output = new LinkedList<>();
this.modelProbeController = new ModelProbeController();
StageTester.test(this.modelProbeController).and().send(input1).to(this.modelProbeController.getInputPort()).receive(output).from(this.modelProbeController.getOutputPort()).start();
Assert.assertTrue(output.isEmpty());
}
use of org.iobserve.service.privacy.violation.data.ProbeManagementData in project iobserve-analysis by research-iobserve.
the class ModelProbeControllerTest method testNullWarningList.
@Test
public void testNullWarningList() {
final WarningModel warnings = new WarningModel();
warnings.setWarningEdges(null);
final List<WarningModel> input1 = new LinkedList<>();
input1.add(warnings);
final List<ProbeManagementData> output = new LinkedList<>();
this.modelProbeController = new ModelProbeController();
StageTester.test(this.modelProbeController).and().send(input1).to(this.modelProbeController.getInputPort()).receive(output).from(this.modelProbeController.getOutputPort()).start();
Assert.assertTrue(output.isEmpty());
}
use of org.iobserve.service.privacy.violation.data.ProbeManagementData in project iobserve-analysis by research-iobserve.
the class ProbeMapperTest method receiveEmptyDataTest.
@Test
public void receiveEmptyDataTest() {
this.probeMapper = new ProbeMapper(Mockito.mock(Neo4JModelResource.class), Mockito.mock(Neo4JModelResource.class), Mockito.mock(Neo4JModelResource.class), Mockito.mock(Neo4JModelResource.class), Mockito.mock(Neo4JModelResource.class));
final ProbeManagementData data = new ProbeManagementData(new HashMap<AllocationContext, Set<OperationSignature>>(), new HashMap<AllocationContext, Set<OperationSignature>>());
final List<ProbeManagementData> input = new LinkedList<>();
input.add(data);
final List<AbstractTcpControlEvent> output = new LinkedList<>();
StageTester.test(this.probeMapper).and().send(input).to(this.probeMapper.getInputPort()).receive(output).from(this.probeMapper.getOutputPort()).start();
Assert.assertTrue(output.isEmpty());
}
use of org.iobserve.service.privacy.violation.data.ProbeManagementData in project iobserve-analysis by research-iobserve.
the class ModelProbeController method execute.
@Override
protected void execute(final WarningModel element) throws Exception {
if (element.getWarningEdges() == null || element.getWarningEdges().isEmpty()) {
this.logger.error("Received warning with empty edge list");
return;
} else {
// ExperimentLoggingUtils.logEvent(element.getEvent().getTimestamp(), EventTypes.NONE,
// ObservationPoint.COMPUTE_PROBE_CONFIGURATION_ENTRY);
final Map<AllocationContext, Set<OperationSignature>> receivedWarnings = this.computeReceivedWarnings(element.getWarningEdges());
final Map<AllocationContext, Set<OperationSignature>> currentWarnings = new HashMap<>(this.currentActiveWarnings);
final ProbeManagementData probeMethodInformation = this.computeWarningDifferences(currentWarnings, receivedWarnings, element.getEvent());
this.currentActiveWarnings = this.computeNewWarningMap(currentWarnings, probeMethodInformation.getMethodsToActivate(), probeMethodInformation.getMethodsToDeactivate());
probeMethodInformation.setProtectedOperations(receivedWarnings);
probeMethodInformation.setOperationsToUpdate(this.currentActiveWarnings);
// ExperimentLoggingUtils.logEvent(element.getEvent().getTimestamp(), EventTypes.NONE,
// ObservationPoint.COMPUTE_PROBE_CONFIGURATION_EXIT);
this.outputPort.send(probeMethodInformation);
}
}
use of org.iobserve.service.privacy.violation.data.ProbeManagementData in project iobserve-analysis by research-iobserve.
the class ModelProbeController method computeWarningDifferences.
private ProbeManagementData computeWarningDifferences(final Map<AllocationContext, Set<OperationSignature>> currentWarnings, final Map<AllocationContext, Set<OperationSignature>> receivedWarnings, final IPCMDeploymentEvent ipcmDeploymentEvent) {
Map<AllocationContext, Set<OperationSignature>> missingWarnings = new HashMap<>();
Map<AllocationContext, Set<OperationSignature>> addedWarnings = new HashMap<>();
missingWarnings = new HashMap<>();
addedWarnings = new HashMap<>();
final Map<AllocationContext, Set<OperationSignature>> newAllocationWarnings = new HashMap<>(receivedWarnings);
// already existing allocations
for (final AllocationContext allocation : currentWarnings.keySet()) {
final Set<OperationSignature> newMethodSet = receivedWarnings.get(allocation);
final Set<OperationSignature> currentMethods = currentWarnings.get(allocation);
// no new allocation -> all old methods have to be deactivated
if (newMethodSet == null) {
missingWarnings.put(allocation, currentMethods);
} else {
// current - new = missing methods = deactivate
final Set<OperationSignature> missingMethods = new HashSet<>(currentMethods);
missingMethods.removeAll(newMethodSet);
// new - current = added methods = activate
final Set<OperationSignature> addedMethods = new HashSet<>(newMethodSet);
addedMethods.removeAll(currentMethods);
if (!missingMethods.isEmpty()) {
missingWarnings.put(allocation, missingMethods);
}
if (!addedMethods.isEmpty()) {
addedWarnings.put(allocation, addedMethods);
}
}
// the remaining entries are completely new warnings and allocations
newAllocationWarnings.remove(allocation);
}
addedWarnings.putAll(newAllocationWarnings);
final ProbeManagementData result = new ProbeManagementData(addedWarnings, missingWarnings);
result.setTriggerTime(ipcmDeploymentEvent.getTimestamp());
return result;
}
Aggregations