Skip to content

Commit f9cbd53

Browse files
gselzerctrueden
authored andcommitted
Remove ugly casts in ProvenanceTest
We can use the OpHistory for this!
1 parent 4dc33c1 commit f9cbd53

2 files changed

Lines changed: 8 additions & 12 deletions

File tree

scijava/scijava-ops-api/src/main/java/org/scijava/ops/api/OpHistory.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ public interface OpHistory {
4545
*/
4646
InfoChain opExecutionChain(Object op);
4747

48+
default String signatureOf(Object op) {
49+
return opExecutionChain(op).signature();
50+
}
51+
4852
// -- HISTORY MAINTENANCE API -- //
4953

5054
/**

scijava/scijava-ops-engine/src/test/java/org/scijava/ops/engine/impl/ProvenanceTest.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,8 @@ public void testOpWithDependencyRecoveryFromString() {
195195
@Test
196196
public void testAdaptationRecoveryFromString() {
197197
Function<Double[], Thing[]> f = ops.op("test.provenanceMapped").inType(Double[].class).outType(Thing[].class).function();
198+
String signature = ops.history().signatureOf(f);
198199
Thing[] apply = f.apply(new Double[] {1., 2., 3.});
199-
@SuppressWarnings("unchecked")
200-
InfoChain chain = ((RichOp<Function<Double[], Thing[]>>) f).infoChain();
201-
String signature = chain.signature();
202200
Nil<Function<Double[], Thing[]>> special = new Nil<>() {};
203201
Nil<Double[]> inType = Nil.of(Double[].class);
204202
Nil<Thing[]> outType = Nil.of(Thing[].class);
@@ -209,9 +207,7 @@ public void testAdaptationRecoveryFromString() {
209207
@Test
210208
public void testAdaptedOpWithDependencies() {
211209
Function<Double[][], Thing[]> f = ops.op("test.provenanceMapper").inType(Double[][].class).outType(Thing[].class).function();
212-
@SuppressWarnings("unchecked")
213-
InfoChain chain = ((RichOp<Function<Double[], Thing[]>>) f).infoChain();
214-
String signature = chain.signature();
210+
String signature = ops.history().signatureOf(f);
215211
Nil<Function<Double[][], Thing[]>> special = new Nil<>() {};
216212
Nil<Double[][]> inType = Nil.of(Double[][].class);
217213
Nil<Thing[]> outType = Nil.of(Thing[].class);
@@ -222,9 +218,7 @@ public void testAdaptedOpWithDependencies() {
222218
@Test
223219
public void testSimplificationRecovery() {
224220
Computers.Arity1<Integer[], Integer[]> c = ops.op("test.provenanceComputer").inType(Integer[].class).outType(Integer[].class).computer();
225-
@SuppressWarnings("unchecked")
226-
InfoChain chain = ((RichOp<Computers.Arity1<Double[], Double[]>>) c).infoChain();
227-
String signature = chain.signature();
221+
String signature = ops.history().signatureOf(c);
228222
Nil<Computers.Arity1<Integer[], Integer[]>> special = new Nil<>() {};
229223
Nil<Integer[]> inType = Nil.of(Integer[].class);
230224
Nil<Integer[]> outType = Nil.of(Integer[].class);
@@ -239,9 +233,7 @@ public void testSimplificationRecovery() {
239233
@Test
240234
public void testSimplificationAdaptationRecovery() {
241235
Function<Integer[], Integer[]> c = ops.op("test.provenanceComputer").inType(Integer[].class).outType(Integer[].class).function();
242-
@SuppressWarnings("unchecked")
243-
InfoChain chain = ((RichOp<Function<Double[], Double[]>>) c).infoChain();
244-
String signature = chain.signature();
236+
String signature = ops.history().signatureOf(c);
245237
Nil<Function<Integer[], Integer[]>> special = new Nil<>() {};
246238
Nil<Integer[]> inType = Nil.of(Integer[].class);
247239
Nil<Integer[]> outType = Nil.of(Integer[].class);

0 commit comments

Comments
 (0)