Skip to content
This repository has been archived by the owner on Jan 8, 2019. It is now read-only.

Commit

Permalink
Add NoOpReturnOutputRestriction
Browse files Browse the repository at this point in the history
  • Loading branch information
maltemoeser committed Aug 1, 2016
1 parent 82a91a4 commit a6d488b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package de.maltemoeser.bcgraph.restrictions.graph;

import de.maltemoeser.bcgraph.entities.BCOutput;
import de.maltemoeser.bcgraph.entities.BCTransaction;
import de.maltemoeser.bcgraph.restrictions.Restriction;


public class NoOpReturnOutputRestriction implements Restriction<BCTransaction> {

@Override
public boolean evaluate(BCTransaction entity) {
for(BCOutput output : entity.getOutputs()) {
if(output.isOpReturn()) {
return false;
}
}
return true;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.maltemoeser.bcgraph.restrictions.graph;

import de.maltemoeser.bcgraph.entities.BCOutput;
import de.maltemoeser.bcgraph.entities.BCTransaction;
import de.maltemoeser.bcgraph.restrictions.EntityRestrictor;
import de.maltemoeser.bcgraph.restrictions.Restrictor;
Expand Down Expand Up @@ -72,4 +73,22 @@ public void testMaxOutputCountRestriction() {
}
}

@Test
public void testNoOpReturnOutputRestriction() {
try (org.neo4j.graphdb.Transaction ignored = graphDatabaseService.beginTx()) {
BCTransaction transaction = getNewTransaction();
BCOutput output = getNewOutput();
transaction.addOutput(getNewOutput());
transaction.addOutput(output);
transaction.addOutput(getNewOutput());

Restrictor<BCTransaction> restrictor = new EntityRestrictor<BCTransaction>()
.restrict(new NoOpReturnOutputRestriction());
assertTrue(restrictor.evaluate(transaction));

output.setOpReturn(true);

assertFalse(restrictor.evaluate(transaction));
}
}
}

0 comments on commit a6d488b

Please sign in to comment.