Skip to content

Commit

Permalink
Adding a simple unit test for EmptyResponseProcessor.
Browse files Browse the repository at this point in the history
  • Loading branch information
Craigacp authored and jhalexand committed Nov 30, 2020
1 parent 4726839 commit 56bb558
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* It still requires an output factory, even though it's never used to generate
* an output, because the output factory provides the type for the columnar infrastructure.
*/
public class EmptyResponseProcessor<T extends Output<T>> implements ResponseProcessor<T> {
public final class EmptyResponseProcessor<T extends Output<T>> implements ResponseProcessor<T> {

public static final String FIELD_NAME = "TRIBUO##NULL_RESPONSE_PROCESSOR";

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.tribuo.data.columnar.processors.response;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.tribuo.test.MockOutput;
import org.tribuo.test.MockOutputFactory;

public class EmptyResponseProcessorTest {

@Test
public void basicTest() {
MockOutputFactory outputFactory = new MockOutputFactory();
EmptyResponseProcessor<MockOutput> rp = new EmptyResponseProcessor<>(outputFactory);

// Check the output factory is stored correctly
Assertions.assertEquals(outputFactory,rp.getOutputFactory());

// Check the field name is right
Assertions.assertEquals(EmptyResponseProcessor.FIELD_NAME, rp.getFieldName());

// setFieldName is a no-op on this response processor
rp.setFieldName("Something");
Assertions.assertEquals(EmptyResponseProcessor.FIELD_NAME, rp.getFieldName());

// Check that it doesn't throw exceptions when given odd text, and that it always returns Optional.empty.
Assertions.assertFalse(rp.process("").isPresent());
Assertions.assertFalse(rp.process("test").isPresent());
Assertions.assertFalse(rp.process("!@$#$!").isPresent());
Assertions.assertFalse(rp.process("\n").isPresent());
Assertions.assertFalse(rp.process("\t").isPresent());
Assertions.assertFalse(rp.process(null).isPresent());
}

}

0 comments on commit 56bb558

Please sign in to comment.