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

The following examples show how to use org.approvaltests.Approvals#verify() . 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: SimpleLoggerTest.java    From ApprovalTests.Java with Apache License 2.0 6 votes vote down vote up
@Test
public void test()
{
  StringBuffer output = SimpleLogger.logToString();
  try (Markers m = SimpleLogger.useMarkers();)
  {
    try (Markers m2 = SimpleLogger.useMarkers();)
    {
      SimpleLogger.event("Starting Logging");
      String name = "llewellyn";
      SimpleLogger.variable("name", name);
      SimpleLogger.query("Select * from people");
      for (int i = 0; i < 42; i++)
      {
        SimpleLogger.hourGlass();
      }
      SimpleLogger.variable("Numbers", new Integer[]{1, 2, 3, 4, 5});
      SimpleLogger.warning(new Error());
    }
  }
  Approvals.verify(output);
}
 
Example 2
Source File: ReceiptPrinterTest.java    From training with MIT License 5 votes vote down vote up
@Test
public void total() {

    receipt.addProduct(toothbrush, 1, 0.99, 2*0.99);
    receipt.addProduct(apples, 0.75, 1.99, 1.99*0.75);
    Approvals.verify(new ReceiptPrinter(40).printReceipt(receipt));
}
 
Example 3
Source File: BrandingServiceIT.java    From restful-booker-platform with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void returnsBrandingData() {
    Response brandingResponse =  given()
            .when()
            .get("http://localhost:3002/branding/");

    Approvals.verify(brandingResponse.getBody().prettyPrint());
}
 
Example 4
Source File: FileUtilsTest.java    From ApprovalTests.Java with Apache License 2.0 5 votes vote down vote up
@UseReporter(ClipboardReporter.class)
@Test
public void testSaveToFile()
{
  Reader input = new StringReader("hello Approvals");
  File file = FileUtils.saveToFile("pre_", input);
  Approvals.verify(file);
}
 
Example 5
Source File: VelocityApprovals.java    From ApprovalTests.Java with Apache License 2.0 5 votes vote down vote up
public static void verify(ContextAware context, String fileExtentsionWithDot)
{
  ApprovalNamer namer = Approvals.createApprovalNamer();
  String file = namer.getSourceFilePath() + namer.getApprovalName() + ".template" + fileExtentsionWithDot;
  FileUtils.createIfNeeded(file);
  String text = VelocityParser.parseFile(file, context);
  Approvals.verify(text, fileExtentsionWithDot.substring(1));
}
 
Example 6
Source File: MessageEndpointsIT.java    From restful-booker-platform with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void getCount(){
    Response response = given()
            .get("http://localhost:3006/message/count");

    Approvals.verify(response.getBody().prettyPrint());
}
 
Example 7
Source File: SupermarketTest.java    From training with MIT License 5 votes vote down vote up
@Test
public void buy_five_get_one_free() {
    theCart.addItem(toothbrush);
    theCart.addItem(toothbrush);
    theCart.addItem(toothbrush);
    theCart.addItem(toothbrush);
    theCart.addItem(toothbrush);
    teller.addSpecialOffer(SpecialOfferType.ThreeForTwo, toothbrush, catalog.getUnitPrice(toothbrush));
    Receipt receipt = teller.checksOutArticlesFrom(theCart);
    Approvals.verify(new ReceiptPrinter(40).printReceipt(receipt));
}
 
Example 8
Source File: MessageEndpointsIT.java    From restful-booker-platform with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void getMessage(){
    Response response = given()
            .get("http://localhost:3006/message/1");

    Approvals.verify(response.getBody().prettyPrint());
}
 
Example 9
Source File: BuildReportIT.java    From restful-booker-platform with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testSpecificRoomReportCreation(){
    Response reportResponse = given()
                                .get("http://localhost:3005/report/room/1");

    Approvals.verify(reportResponse.getBody().prettyPrint());
}
 
Example 10
Source File: DateRangeTest.java    From ApprovalTests.Java with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetRangeContaining() throws Exception
{
  DateRange d = new DateRange(DateUtils.parse("2008/01/01"), DateUtils.parse("2009/01/01"));
  DateRange containing = DateRange.getRangeContaining(d.getQuarters(), d.getMonths()[0]);
  Approvals.verify(containing.toString());
}
 
Example 11
Source File: ApiTest.java    From api-framework with MIT License 5 votes vote down vote up
@Test
public void getBookingIdWithBadAcceptShouldReturn418(){
    try{
        Booking.getBooking(1, MediaType.TEXT_PLAIN);

        fail("HttpClientError not thrown");
    } catch (HttpClientErrorException e){
        Approvals.verify(e.getStatusCode());
    }
}
 
Example 12
Source File: GenericDiffReporterTest.java    From ApprovalTests.Java with Apache License 2.0 5 votes vote down vote up
private void approveGenericReporter(String a, String b, GenericDiffReporter reporter)
{
  File directory = ClassUtils.getSourceDirectory(getClass());
  String aPath = directory.getAbsolutePath() + File.separator + a;
  String bPath = directory.getAbsolutePath() + File.separator + b;
  Approvals.verify(new QueryableDiffReporterHarness(reporter, aPath, bPath));
}
 
Example 13
Source File: SupermarketTest.java    From training with MIT License 5 votes vote down vote up
@Test
public void buy_two_get_one_free_but_insufficient_in_basket() {
    theCart.addItem(toothbrush);
    teller.addSpecialOffer(SpecialOfferType.ThreeForTwo, toothbrush, catalog.getUnitPrice(toothbrush));
    Receipt receipt = teller.checksOutArticlesFrom(theCart);
    Approvals.verify(new ReceiptPrinter(40).printReceipt(receipt));
}
 
Example 14
Source File: PackageSettingsTest.java    From ApprovalTests.Java with Apache License 2.0 5 votes vote down vote up
private void failApproval()
{
  try
  {
    Approvals.verify("foo");
  }
  catch (Throwable e)
  {
    // ignore
  }
}
 
Example 15
Source File: DatabaseWriterTest.java    From ApprovalTests.Java with Apache License 2.0 4 votes vote down vote up
@Test
public void testSimpleQuery() throws Exception
{
  ResultSet rs = mockResultSetFromFile("query.csv");
  Approvals.verify(rs);
}
 
Example 16
Source File: DatabaseWriterTest.java    From ApprovalTests.Java with Apache License 2.0 4 votes vote down vote up
@Test
public void testSimpleQuery2() throws Exception
{
  ResultSet rs = queryDatabase();
  Approvals.verify(rs);
}
 
Example 17
Source File: ApiTest.java    From api-framework with MIT License 4 votes vote down vote up
@Test
public void getBookingIdWithBadAcceptShouldReturn418(){
    Response response = BookingApi.getBooking(1, "text/plain");

    Approvals.verify(response.getStatusCode());
}
 
Example 18
Source File: ApiTest.java    From api-framework with MIT License 4 votes vote down vote up
@Test
public void getBookingIdShouldReturn200(){
    Response response = BookingApi.getBooking(1, "application/json");

    Approvals.verify(response.getStatusCode());
}
 
Example 19
Source File: ApprovalsUtil.java    From recheck with GNU Affero General Public License v3.0 4 votes vote down vote up
private static void verify( final String actual, final String fileExtensionWithoutDot ) {
	Approvals.verify( new ApprovalTextWriter( actual, fileExtensionWithoutDot ),
			new MavenConformJUnitStackTraceNamer(), DIFF_HANDLER );
}
 
Example 20
Source File: WebPageApproval.java    From ApprovalTests.Java with Apache License 2.0 4 votes vote down vote up
public static void verifyRenderedPage(URI uri)
{
  String imageFile = convertToLegalFileName(uri, "png");
  captureWebPage(uri, imageFile);
  Approvals.verify(new File(imageFile));
}