Java Code Examples for org.supercsv.cellprocessor.ift.CellProcessor#execute()

The following examples show how to use org.supercsv.cellprocessor.ift.CellProcessor#execute() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FmtIntervalTest.java    From super-csv with Apache License 2.0 5 votes vote down vote up
@Test
public void testNullInput() {
	for (CellProcessor p : processors) {
		try {
			p.execute(null, ANONYMOUS_CSVCONTEXT);
			fail("expecting SuperCsvCellProcessorException");
		} catch (SuperCsvCellProcessorException e) {
			assertEquals(
					"this processor does not accept null input - "
							+ "if the column is optional then chain an Optional() processor before this one",
					e.getMessage());
		}
	}
}
 
Example 2
Source File: ParseLocalDateTimeTest.java    From super-csv with Apache License 2.0 5 votes vote down vote up
@Test
public void testNullInput() {
	for (CellProcessor p : processors) {
		try {
			p.execute(null, ANONYMOUS_CSVCONTEXT);
			fail("expecting SuperCsvCellProcessorException");
		} catch (SuperCsvCellProcessorException e) {
			assertEquals(
					"this processor does not accept null input - "
							+ "if the column is optional then chain an Optional() processor before this one",
					e.getMessage());
		}
	}
}
 
Example 3
Source File: ParseLocalTimeTest.java    From super-csv with Apache License 2.0 5 votes vote down vote up
@Test
public void testNullInput() {
	for (CellProcessor p : processors) {
		try {
			p.execute(null, ANONYMOUS_CSVCONTEXT);
			fail("expecting SuperCsvCellProcessorException");
		} catch (SuperCsvCellProcessorException e) {
			assertEquals(
					"this processor does not accept null input - "
							+ "if the column is optional then chain an Optional() processor before this one",
					e.getMessage());
		}
	}
}
 
Example 4
Source File: FmtDurationTest.java    From super-csv with Apache License 2.0 5 votes vote down vote up
@Test
public void testNullInput() {
	for (CellProcessor p : processors) {
		try {
			p.execute(null, ANONYMOUS_CSVCONTEXT);
			fail("expecting SuperCsvCellProcessorException");
		} catch (SuperCsvCellProcessorException e) {
			assertEquals(
					"this processor does not accept null input - "
							+ "if the column is optional then chain an Optional() processor before this one",
					e.getMessage());
		}
	}
}
 
Example 5
Source File: FmtLocalDateTest.java    From super-csv with Apache License 2.0 5 votes vote down vote up
@Test
public void testNullInput() {
	for (CellProcessor p : processors) {
		try {
			p.execute(null, ANONYMOUS_CSVCONTEXT);
			fail("expecting SuperCsvCellProcessorException");
		} catch (SuperCsvCellProcessorException e) {
			assertEquals(
					"this processor does not accept null input - "
							+ "if the column is optional then chain an Optional() processor before this one",
					e.getMessage());
		}
	}
}
 
Example 6
Source File: ParsePeriodTest.java    From super-csv with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnparsableString() {
	for (CellProcessor p : processors) {
		try {
			p.execute("not valid", ANONYMOUS_CSVCONTEXT);
			fail("expecting SuperCsvCellProcessorException");
		} catch (SuperCsvCellProcessorException e) {
			assertEquals("Failed to parse value as a Period", e.getMessage());
		}
	}
}
 
Example 7
Source File: ParsePeriodTest.java    From super-csv with Apache License 2.0 5 votes vote down vote up
@Test
public void testNonStringInput() {
	for (CellProcessor p : processors) {
		try {
			p.execute(123, ANONYMOUS_CSVCONTEXT);
			fail("expecting SuperCsvCellProcessorException");
		} catch (SuperCsvCellProcessorException e) {
			assertEquals(
					"the input value should be of type java.lang.String but is java.lang.Integer",
					e.getMessage());
		}
	}
}
 
Example 8
Source File: FmtLocalTimeTest.java    From super-csv with Apache License 2.0 5 votes vote down vote up
@Test
public void testInvalidDateFormat() {
	final CellProcessor p = new FmtLocalTime("not valid");
	try {
		p.execute(LOCAL_TIME, ANONYMOUS_CSVCONTEXT);
		fail("expecting SuperCsvCellProcessorException");
	} catch (SuperCsvCellProcessorException e) {
		assertEquals("Failed to format value as a LocalTime",
				e.getMessage());
	}
}
 
Example 9
Source File: ParseDurationTest.java    From super-csv with Apache License 2.0 5 votes vote down vote up
@Test
public void testNonStringInput() {
	for (CellProcessor p : processors) {
		try {
			p.execute(123, ANONYMOUS_CSVCONTEXT);
			fail("expecting SuperCsvCellProcessorException");
		} catch (SuperCsvCellProcessorException e) {
			assertEquals(
					"the input value should be of type java.lang.String but is java.lang.Integer",
					e.getMessage());
		}
	}
}
 
Example 10
Source File: ParseLocalDateTimeTest.java    From super-csv with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnparsableString() {
	for (CellProcessor p : processors) {
		try {
			p.execute("not valid", ANONYMOUS_CSVCONTEXT);
			fail("expecting SuperCsvCellProcessorException");
		} catch (SuperCsvCellProcessorException e) {
			assertEquals("Failed to parse value", e.getMessage());
		}
	}
}
 
Example 11
Source File: FmtDateTimeTest.java    From super-csv with Apache License 2.0 5 votes vote down vote up
@Test
public void testNullInput() {
	for (CellProcessor p : processors) {
		try {
			p.execute(null, ANONYMOUS_CSVCONTEXT);
			fail("expecting SuperCsvCellProcessorException");
		} catch (SuperCsvCellProcessorException e) {
			assertEquals(
					"this processor does not accept null input - "
							+ "if the column is optional then chain an Optional() processor before this one",
					e.getMessage());
		}
	}
}
 
Example 12
Source File: FmtLocalDateTimeTest.java    From super-csv with Apache License 2.0 5 votes vote down vote up
@Test
public void testInvalidDateFormat() {
	final CellProcessor p = new FmtLocalDateTime("not valid");
	try {
		p.execute(LOCAL_DATE_TIME, ANONYMOUS_CSVCONTEXT);
		fail("expecting SuperCsvCellProcessorException");
	} catch (SuperCsvCellProcessorException e) {
		assertEquals("Failed to format value as a LocalDateTime",
				e.getMessage());
	}
}
 
Example 13
Source File: ParseLocalDateTest.java    From super-csv with Apache License 2.0 5 votes vote down vote up
@Test
public void testNullInput() {
	for (CellProcessor p : processors) {
		try {
			p.execute(null, ANONYMOUS_CSVCONTEXT);
			fail("expecting SuperCsvCellProcessorException");
		} catch (SuperCsvCellProcessorException e) {
			assertEquals(
					"this processor does not accept null input - "
							+ "if the column is optional then chain an Optional() processor before this one",
					e.getMessage());
		}
	}
}
 
Example 14
Source File: ParseIntervalTest.java    From super-csv with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnparsableString() {
	for (CellProcessor p : processors) {
		try {
			p.execute("not valid", ANONYMOUS_CSVCONTEXT);
			fail("expecting SuperCsvCellProcessorException");
		} catch (SuperCsvCellProcessorException e) {
			assertEquals("Failed to parse value as an Interval",
					e.getMessage());
		}
	}
}
 
Example 15
Source File: ParseIntervalTest.java    From super-csv with Apache License 2.0 5 votes vote down vote up
@Test
public void testNonStringInput() {
	for (CellProcessor p : processors) {
		try {
			p.execute(123, ANONYMOUS_CSVCONTEXT);
			fail("expecting SuperCsvCellProcessorException");
		} catch (SuperCsvCellProcessorException e) {
			assertEquals(
					"the input value should be of type java.lang.String but is java.lang.Integer",
					e.getMessage());
		}
	}
}
 
Example 16
Source File: ParseIntervalTest.java    From super-csv with Apache License 2.0 5 votes vote down vote up
@Test
public void testNullInput() {
	for (CellProcessor p : processors) {
		try {
			p.execute(null, ANONYMOUS_CSVCONTEXT);
			fail("expecting SuperCsvCellProcessorException");
		} catch (SuperCsvCellProcessorException e) {
			assertEquals(
					"this processor does not accept null input - "
							+ "if the column is optional then chain an Optional() processor before this one",
					e.getMessage());
		}
	}
}
 
Example 17
Source File: ParseDateTimeTest.java    From super-csv with Apache License 2.0 5 votes vote down vote up
@Test
public void testNullInput() {
	for (CellProcessor p : processors) {
		try {
			p.execute(null, ANONYMOUS_CSVCONTEXT);
			fail("expecting SuperCsvCellProcessorException");
		} catch (SuperCsvCellProcessorException e) {
			assertEquals(
					"this processor does not accept null input - "
							+ "if the column is optional then chain an Optional() processor before this one",
					e.getMessage());
		}
	}
}
 
Example 18
Source File: FmtLocalTimeTest.java    From super-csv with Apache License 2.0 5 votes vote down vote up
@Test
public void testNullInput() {
	for (CellProcessor p : processors) {
		try {
			p.execute(null, ANONYMOUS_CSVCONTEXT);
			fail("expecting SuperCsvCellProcessorException");
		} catch (SuperCsvCellProcessorException e) {
			assertEquals(
					"this processor does not accept null input - "
							+ "if the column is optional then chain an Optional() processor before this one",
					e.getMessage());
		}
	}
}
 
Example 19
Source File: FmtDateTimeTest.java    From super-csv with Apache License 2.0 5 votes vote down vote up
@Test
public void testNonDateTimeInput() {
	for (CellProcessor p : processors) {
		try {
			p.execute(123, ANONYMOUS_CSVCONTEXT);
			fail("expecting SuperCsvCellProcessorException");
		} catch (SuperCsvCellProcessorException e) {
			assertEquals(
					"the input value should be of type org.joda.time.DateTime but is java.lang.Integer",
					e.getMessage());
		}
	}
}
 
Example 20
Source File: FmtSqlTimeTest.java    From super-csv with Apache License 2.0 4 votes vote down vote up
/**
 * Tests execution with a invalid date format (should throw an Exception).
 */
@Test(expected = SuperCsvCellProcessorException.class)
public void testWithInvalidDateFormat() {
	CellProcessor invalidDateFormatProcessor = new FmtSqlTime("abcd");
	invalidDateFormatProcessor.execute(TIME, ANONYMOUS_CSVCONTEXT);
}