How to use drawOval method of com.tngtech.jgiven.examples.attachments.AttachmentsExampleStage class

Best JGiven code snippet using com.tngtech.jgiven.examples.attachments.AttachmentsExampleStage.drawOval

Source:AttachmentsExampleStage.java Github

copy

Full Screen

...34 public void a_$_oval_circle( String color ) throws IOException {35 addOvalAttachment( 300, 200, getColor( color ), "oval-circle" );36 }37 public void an_oval_circle_as_thumbnail() throws IOException {38 byte[] bytes = drawOval(300, 200, Color.BLUE);39 currentStep.addAttachment(40 Attachment.fromBinaryBytes( bytes, MediaType.PNG )41 .withTitle( "An oval drawn in Java" )42 .withFileName( "oval-circle-as-thumbnail" ));43 }44 private Color getColor( String color ) {45 if( color.equals( "red" ) ) {46 return Color.RED;47 }48 return Color.BLUE;49 }50 private void addOvalAttachment(int width, int height, Color color, String fileName ) throws IOException {51 byte[] bytes = drawOval(width, height, color);52 currentStep.addAttachment(53 Attachment.fromBinaryBytes( bytes, MediaType.PNG )54 .withTitle( "An oval drawn in Java" )55 .withFileName( fileName )56 .showDirectly() );57 }58 private byte[] drawOval(int width, int height, Color color) throws IOException {59 BufferedImage image = new BufferedImage( width, height, BufferedImage.TYPE_INT_ARGB );60 Graphics2D g = image.createGraphics();61 g.setRenderingHint( RenderingHints.KEY_ANTIALIASING,62 RenderingHints.VALUE_ANTIALIAS_ON );63 g.setStroke( new BasicStroke( 10 ) );64 g.setPaint( color );65 g.drawOval( 10, 10, width - 20, height - 20 );66 ByteArrayOutputStream outputStream = new ByteArrayOutputStream();67 byte[] bytes;68 try {69 ImageIO.write( image, "PNG", outputStream );70 bytes = outputStream.toByteArray();71 } finally {72 outputStream.close();73 }74 return bytes;75 }76}...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful