ResultFunctionFactory { public final IResultFunction create (final String result) { if (result.compareTo(RESULT_AND) == 0) { return new AndResultFunction(); } else if (result.compareTo(RESULT_OR) == 0) { return new OrResultFunction(); } else if (result.compareTo(RESULT_MIN) == 0) { return new MinResultFunction(); } else if (result.compareTo(RESULT_MAX) == 0) { return new MaxResultFunction(); } else if (result.compareTo(RESULT_CHOOSE) == 0) { return new ChooseResultFunction(); } else if (result.compareTo(RESULT_NONE) == 0) { return new NoneResultFunction(); } else { throw new UnsupportedOperationException(); } }  final IResultFunction create(final String result);  }
@Test public final void testValidChoose1 () { final ResultFunctionFactory resultFunctionFactory = new ResultFunctionFactory(); final IResultFunction resultFunction = resultFunctionFactory.create("Choose"); assertTrue(resultFunction instanceof ChooseResultFunction); assertEquals("CRC32CDigest", resultFunction.result("CRC32CDigest,None", "MD5,CRC32CDigest,None")); }
@Test public final void testValidChoose2 () { final ResultFunctionFactory resultFunctionFactory = new ResultFunctionFactory(); final IResultFunction resultFunction = resultFunctionFactory.create("Choose"); assertTrue(resultFunction instanceof ChooseResultFunction); assertEquals("None", resultFunction.result("CRC32,None", "MD5,CRC32CDigest,None")); }
@Test (expectedExceptions = NoSuchElementException.class) public final void testInvalidChoose () { final ResultFunctionFactory resultFunctionFactory = new ResultFunctionFactory(); final IResultFunction resultFunction = resultFunctionFactory.create("Choose"); assertTrue(resultFunction instanceof ChooseResultFunction); resultFunction.result("CRC32", "MD5,CRC32CDigest"); }