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 Project: super-csv   File: FmtDateTimeTest.java    License: 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 Project: super-csv   File: FmtDateTimeTest.java    License: 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 3
Source Project: super-csv   File: FmtLocalTimeTest.java    License: 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 Project: super-csv   File: ParseDateTimeTest.java    License: 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 Project: super-csv   File: ParseIntervalTest.java    License: 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 Project: super-csv   File: ParseIntervalTest.java    License: 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 7
Source Project: super-csv   File: ParseIntervalTest.java    License: 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 8
Source Project: super-csv   File: ParseLocalDateTest.java    License: 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 9
Source Project: super-csv   File: FmtLocalDateTimeTest.java    License: 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 10
Source Project: super-csv   File: FmtIntervalTest.java    License: 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 11
@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 12
Source Project: super-csv   File: ParseDurationTest.java    License: 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 13
Source Project: super-csv   File: FmtLocalTimeTest.java    License: 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 14
Source Project: super-csv   File: ParsePeriodTest.java    License: 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 15
Source Project: super-csv   File: ParsePeriodTest.java    License: 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 16
Source Project: super-csv   File: FmtLocalDateTest.java    License: 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 Project: super-csv   File: FmtDurationTest.java    License: 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 Project: super-csv   File: ParseLocalTimeTest.java    License: 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
@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 20
Source Project: super-csv   File: FmtSqlTimeTest.java    License: 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);
}