Spark2BitcoinBlockCounter { public static Tuple2<String,Long> mapNoOfTransaction(BitcoinBlock block) { return new Tuple2<String, Long>("No of transactions: ",(long)(block.getTransactions().size())); } Spark2BitcoinBlockCounter(); static void main(String[] args); static void jobTotalNumOfTransactions(JavaSparkContext sc, Configuration hadoopConf, String inputFile, String outputFile); static Tuple2<String,Long> mapNoOfTransaction(BitcoinBlock block); static Long reduceSumUpTransactions(Long a, Long b);  }
@Test public void mapNoOfTransaction() { Spark2BitcoinBlockCounter sparkTransformator = new Spark2BitcoinBlockCounter(); BitcoinBlock testBlock = new BitcoinBlock(); BitcoinTransaction testTransaction = new BitcoinTransaction(); ArrayList<BitcoinTransaction> testTransactionList = new ArrayList<BitcoinTransaction>(); testTransactionList.add(testTransaction); testBlock.setTransactions(testTransactionList); Tuple2<String,Long> result = sparkTransformator.mapNoOfTransaction(testBlock); assertEquals((long)1,(long)result._2(),"One transaction should have been mapped"); }