ContractUtil { @SuppressWarnings({ "unchecked" }) public static Class<? extends Contract> getContractClass(final Class<?> stubClass) { if (stubClass == null) return null; final Class<?> contract = STUB_CONTRACTS.get(stubClass); if (contract != null) return (Class<? extends Contract>) contract; Iterator<Entry<Class<?>, Class<? extends Contract>>> stubContracts = STUB_CONTRACTS.entrySet().iterator(); while (stubContracts.hasNext()) { Map.Entry<Class<?>, Class<? extends Contract>> entry = stubContracts.next(); if (entry.getKey().isAssignableFrom(stubClass)) return entry.getValue(); } return null; }  @SuppressWarnings({ "unchecked" }) static Class<? extends Contract> getContractClass(final Class<?> stubClass); static int getNumInputs(final Class<? extends Contract> contractType); static List<List<Contract>> getInputs(final Contract contract); static List<Contract> getFlatInputs(final Contract contract); static void setInputs(final Contract contract, final List<List<Contract>> inputs); static void swapInputs(Contract contract, int input1, int input2);  }
@Test public void getContractClassShouldReturnCoGroupForCoGroupStub() { final Class<?> result = ContractUtil.getContractClass(CoGrouper.class); assertEquals(CoGroupContract.class, result); }
@Test public void getContractClassShouldReturnCrossForCrossStub() { final Class<?> result = ContractUtil.getContractClass(Crosser.class); assertEquals(CrossContract.class, result); }
@Test public void getContractClassShouldReturnMapForMapStub() { final Class<?> result = ContractUtil.getContractClass(Mapper.class); assertEquals(MapContract.class, result); }
@Test public void getContractClassShouldReturnMatchForMatchStub() { final Class<?> result = ContractUtil.getContractClass(Matcher.class); assertEquals(MatchContract.class, result); }
@Test public void getContractClassShouldReturnNullForStub() { final Class<?> result = ContractUtil.getContractClass(Stub.class); assertEquals(null, result); }
@Test public void getContractClassShouldReturnReduceForReduceStub() { final Class<?> result = ContractUtil.getContractClass(Reducer.class); assertEquals(ReduceContract.class, result); }
@Test public void getContractClassShouldReturnSinkForOutputFormat() { final Class<?> result = ContractUtil.getContractClass(DelimitedOutputFormat.class); assertEquals(FileDataSink.class, result); }
@Test public void getContractClassShouldReturnSourceForInputFormat() { final Class<?> result = ContractUtil.getContractClass(DelimitedInputFormat.class); assertEquals(FileDataSource.class, result); }