### Question:
RemoveSubstringTransformer implements Transformer { @Override public String[] transform(final InputRow inputRow) { String subtractedString = inputRow.getValue(baseColumn); for (final InputColumn<?> inputColumn : substringColumns) { final Object value = inputRow.getValue(inputColumn); if (value instanceof List) { for (final Object element : (List<?>) value) { subtractedString = subtract(subtractedString, element); } } else { subtractedString = subtract(subtractedString, value); } } return new String[] { subtractedString }; }  @Override OutputColumns getOutputColumns(); @Override String[] transform(final InputRow inputRow);  }### Answer:
@Test public void testTransformSimpleRemoval() { final String[] result = _transformer.transform(_inputRow); Assert.assertEquals(1, result.length); Assert.assertEquals("hello good, , , , c, , flse", result[0]); }
@Test public void testTransformSimpleCaseSensitiveNonMatch() { final String[] result = _transformer.transform(new MockInputRow().put(_transformer.baseColumn, "GOOD BYE CASE SENSITIVE GUY")); Assert.assertEquals(1, result.length); Assert.assertEquals("GOOD BYE CASE SENSITIVE GUY", result[0]); }
@Test public void testTransformSimpleNonRemoval() { final String[] result = _transformer.transform(new MockInputRow().put(_transformer.baseColumn, "nothing of interest here")); Assert.assertEquals(1, result.length); Assert.assertEquals("nothing of interest here", result[0]); }
@Test public void testTransformNullBaseColumn() { final String[] result = _transformer.transform(new MockInputRow().put(_transformer.baseColumn, null)); Assert.assertEquals(1, result.length); Assert.assertEquals(null, result[0]); }
@Test public void testTransformNullReplacementColumn() { final String[] result = _transformer.transform(new MockInputRow().put(_transformer.baseColumn, "foo")); Assert.assertEquals(1, result.length); Assert.assertEquals("foo", result[0]); }
@Test public void testTransformWholeWords() { _transformer.wholeWordsOnly = true; final String[] result = _transformer.transform(_inputRow); Assert.assertEquals(1, result.length); Assert.assertEquals("hello goodbye, , , , c, , ", result[0]); }
@Test public void testTransformCaseInsensitive() throws Exception { _transformer.caseSensitive = false; _transformer.wholeWordsOnly = false; final String[] result = _transformer.transform( new MockInputRow().put(_transformer.baseColumn, "HELLO GOODBYE DUDE").put(_stringColumn, "bye")); Assert.assertEquals(1, result.length); Assert.assertEquals("HELLO GOOD DUDE", result[0]); }
@Test public void testTransformCaseInsensitiveWholeWords() throws Exception { _transformer.caseSensitive = false; _transformer.wholeWordsOnly = true; final String[] result1 = _transformer.transform( new MockInputRow().put(_transformer.baseColumn, "HELLO GOODBYE DUDE").put(_stringColumn, "bye")); Assert.assertEquals(1, result1.length); Assert.assertEquals("HELLO GOODBYE DUDE", result1[0]); final String[] result2 = _transformer.transform( new MockInputRow().put(_transformer.baseColumn, "HELLO GOOD BYE DUDE").put(_stringColumn, "bye")); Assert.assertEquals(1, result2.length); Assert.assertEquals("HELLO GOOD DUDE", result2[0]); }