Java Code Examples for org.approvaltests.Approvals#verifyAll()

The following examples show how to use org.approvaltests.Approvals#verifyAll() . 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: ConfigXMLFileWriterTest.java    From ApprovalTests.Java with Apache License 2.0 5 votes vote down vote up
@Test
public void testFields()
{
  Field[] fields = ConfigXMLFileWriter.getFields(getClass(), "IGNORED_FIELD");
  List<String> names = Query.select(fields, a -> (a.getName()));
  Approvals.verifyAll("Field", names);
}
 
Example 2
Source File: HadoopApprovals.java    From ApprovalTests.Java with Apache License 2.0 5 votes vote down vote up
public static void verifyMapping(SmartMapper mapper, Object key, Object input) throws Exception
{
  MapDriver mapDriver = new MapDriver();
  mapDriver.setMapper(mapper);
  Object writableKey = WritableUtils.createWritable(key, mapper.getKeyInType());
  Object writableValue = WritableUtils.createWritable(input, mapper.getValueInType());
  mapDriver.withInput(writableKey, writableValue);
  List results = mapDriver.run();
  Collections.sort(results, PairComparer.INSTANCE);
  String header = String.format("[%s]\n\n -> maps via %s to -> \n", input, mapper.getClass().getSimpleName());
  Approvals.verifyAll(header, results, Echo.INSTANCE);
}
 
Example 3
Source File: AttributeStackSelectorTest.java    From ApprovalTests.Java with Apache License 2.0 5 votes vote down vote up
@Test
void unrollLambda()
{
  String[] methodNames = {"doStuff", "lambda$handleCallback$0"};
  Approvals.verifyAll("unroll lambda", methodNames,
      m -> String.format("%s -> %s", m, TestUtils.unrollLambda(m)));
}
 
Example 4
Source File: DateDifferenceTest.java    From ApprovalTests.Java with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetTimeText()
{
  try (WithTimeZone tz = new WithTimeZone())
  {
    Approvals.verifyAll("getTimeText", getTimeTextUseCases(),
        useCase -> useCase + " -> " + new DateDifference(useCase.milli).getTimeText(useCase.amount,
            useCase.maxUnit, useCase.minUnit, useCase.nowText, useCase.agoText, useCase.units));
  }
}
 
Example 5
Source File: GenericDiffReporterTest.java    From ApprovalTests.Java with Apache License 2.0 5 votes vote down vote up
@Test
public void testSpacesInFileNames()
{
  GenericDiffReporter reporter = new GenericDiffReporter(null, "-left=%s -right=%s", null, null);
  String[] commandLine = reporter.getCommandLine("file with spaces", "file with spaces.approved");
  Approvals.verifyAll("arguments", commandLine);
}
 
Example 6
Source File: GenericDiffReporterTest.java    From ApprovalTests.Java with Apache License 2.0 5 votes vote down vote up
@Test
public void testIsImage()
{
  String[] files = {"a.png", "a.viz.png", "a.bitmap", "a.txt"};
  Approvals.verifyAll(files, a -> String.format("Image: %s = %s", a,
      GenericDiffReporter.isFileExtensionValid(a, GenericDiffReporter.IMAGE_FILE_EXTENSIONS)));
}
 
Example 7
Source File: WhiteSpaceStripperTest.java    From ApprovalTests.Java with Apache License 2.0 5 votes vote down vote up
@Test
public void test()
{
  String[] useCases = {"  hello \n    \n   \n", "  hello \r\n    \n a \n", "  hello  "};
  Approvals.verifyAll("whitespace", useCases,
      u -> String.format("---\n%s\n--- ->---\n%s\n---\n", u, WhiteSpaceStripper.stripBlankLines(u)));
}
 
Example 8
Source File: HadoopApprovals.java    From ApprovalTests.Java with Apache License 2.0 5 votes vote down vote up
public static void verifyMapping(SmartMapper mapper, Object key, Object input) throws Exception
{
  MapDriver mapDriver = new MapDriver();
  mapDriver.setMapper(mapper);
  Object writableKey = WritableUtils.createWritable(key, mapper.getKeyInType());
  Object writableValue = WritableUtils.createWritable(input, mapper.getValueInType());
  mapDriver.withInput(writableKey, writableValue);
  List results = mapDriver.run();
  Collections.sort(results, PairComparer.INSTANCE);
  String header = String.format("[%s]\n\n -> maps via %s to -> \n", input, mapper.getClass().getSimpleName());
  Approvals.verifyAll(header, results, Echo.INSTANCE);
}
 
Example 9
Source File: DateRangeTest.java    From ApprovalTests.Java with Apache License 2.0 5 votes vote down vote up
@Test
public void testFilter() throws Exception
{
  DateRange range = new DateRange(quickDate(20), quickDate(40));
  Timestamp dates[] = {quickDate(50), quickDate(40), quickDate(30), quickDate(20), quickDate(10)};
  Approvals.verifyAll("Dates", Query.where(dates, d -> range.contains(d)));
}
 
Example 10
Source File: F1Test.java    From ApprovalTests.Java with Apache License 2.0 5 votes vote down vote up
@Test
public void testIntersection() throws Exception
{
  List<Integer> list1 = Arrays.asList(1, 2, 3, 4);
  final List<Integer> list2 = Arrays.asList(3, 2);
  Approvals.verifyAll("", Query.where(list1, a -> list2.contains(a)));
}
 
Example 11
Source File: OrderByTest.java    From ApprovalTests.Java with Apache License 2.0 4 votes vote down vote up
@Test
public void testString()
{
  String[] names = {"Robert", "Lynn", "Samantha", "Marsha", "Llewellyn"};
  Approvals.verifyAll("i", Query.orderBy(names, a -> a));
}
 
Example 12
Source File: ArrayUtilsTest.java    From ApprovalTests.Java with Apache License 2.0 4 votes vote down vote up
@Test
public void testAddToArray()
{
  Integer[] i = {5, 6, 7};
  Approvals.verifyAll("numbers", ArrayUtils.addToArray(i, 1));
}
 
Example 13
Source File: DateRangeTest.java    From ApprovalTests.Java with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetMonths() throws Exception
{
  DateRange d = new DateRange(DateUtils.parse("2008/01/01"), DateUtils.parse("2009/01/01"));
  Approvals.verifyAll("months", d.getMonths());
}
 
Example 14
Source File: F1Test.java    From ApprovalTests.Java with Apache License 2.0 4 votes vote down vote up
@Test
public void testEvenNumbers() throws Exception
{
  Integer[] list = Range.get(1, 100);
  Approvals.verifyAll("", Query.where(list, a -> (a % 3 == 0)));
}
 
Example 15
Source File: F1Test.java    From ApprovalTests.Java with Apache License 2.0 4 votes vote down vote up
@Test
public void testSquare() throws Exception
{
  List<Integer> list = Arrays.asList(1, 2, 3, 4);
  Approvals.verifyAll("", Query.select(list, a -> a * a));
}
 
Example 16
Source File: OrderByTest.java    From ApprovalTests.Java with Apache License 2.0 4 votes vote down vote up
@Test
public void testStringMethods()
{
  String[] names = {"Robert", "Lynn", "Samantha", "Marsha", "Llewellynn"};
  Approvals.verifyAll("i", Query.orderBy(names, a -> a.length()));
}
 
Example 17
Source File: CountryTest.java    From ApprovalTests.Java with Apache License 2.0 4 votes vote down vote up
@Test
public void allCountries()
{
  Approvals.verifyAll("Countries", Country.getStringValues());
}
 
Example 18
Source File: AllPointsTest.java    From ApprovalTests.Java with Apache License 2.0 4 votes vote down vote up
@Test
public void testAllPoints()
{
  Point[] p = AllPoints.get(1, 2, 9, 10);
  Approvals.verifyAll("point", p);
}
 
Example 19
Source File: LegacyApprovalsTest.java    From ApprovalTests.Java with Apache License 2.0 4 votes vote down vote up
@Test
public void testSizes()
{
  Approvals.verifyAll("size", LegacyApprovals.getSizes(new String[9], new String[3], new String[5]));
}
 
Example 20
Source File: IndexPermutationsTest.java    From ApprovalTests.Java with Apache License 2.0 4 votes vote down vote up
@Test
public void testSizes()
{
  Approvals.verifyAll("type", new IndexPermutations(new Integer[]{3, 4, 1, 2}));
}