org.junit.experimental.theories.suppliers.TestedOn Java Examples

The following examples show how to use org.junit.experimental.theories.suppliers.TestedOn. 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: BufferFormatterPropertyTest.java    From gflogger with Apache License 2.0 6 votes vote down vote up
@Theory( nullsAccepted = false )
public void appendedDoubleWithPrecisionParsesAsItselfWithToleranceCB( final Double value,
                                                                      @TestedOn( ints = { 0, 1, 2, 3, 10, 16, 19, 20 } )
                                                                      final int digits ) {
	final CharBuffer buffer = CharBuffer.allocate( 50 );
	BufferFormatter.append( buffer, value, digits );
	final String formatted = BufferFormatterTest.toString( buffer );

	final double parsedValue = Double.parseDouble( formatted );

	assertThat(
			".append(" + value + "," + digits + ") -> [" + formatted + "] -> [" + parsedValue + "]",
			parsedValue,
			closeTo( value, tolerance( digits ) )
	);
}
 
Example #2
Source File: BufferFormatterPropertyTest.java    From gflogger with Apache License 2.0 6 votes vote down vote up
@Theory( nullsAccepted = false )
public void appendedDoubleWithPrecisionParsesAsItselfWithTolerance( final Double value,
                                                                    @TestedOn( ints = { 0, 1, 2, 3, 10, 16, 19, 20 } )
                                                                    final int digits ) {
	final ByteBuffer buffer = ByteBuffer.allocate( 50 );
	BufferFormatter.append( buffer, value, digits );
	final String formatted = BufferFormatterTest.toString( buffer );

	final double parsedValue = Double.parseDouble( formatted );

	assertThat(
			".append(" + value + "," + digits + ") -> [" + formatted + "] -> [" + parsedValue + "]",
			parsedValue,
			closeTo( value, tolerance( digits ) )
	);
}
 
Example #3
Source File: TestGrid.java    From latexdraw with GNU General Public License v3.0 4 votes vote down vote up
@Theory
public void testGetSetSubGridDots(@TestedOn(ints = {0, 1, 10}) final int value) {
	shape.setSubGridDots(value);
	assertEquals(value, shape.getSubGridDots());
}
 
Example #4
Source File: TestGrid.java    From latexdraw with GNU General Public License v3.0 4 votes vote down vote up
@Theory
public void testGetSetSubGridDiv(@TestedOn(ints = {0, 1, 10}) final int value) {
	shape.setSubGridDiv(value);
	assertEquals(value, shape.getSubGridDiv());
}
 
Example #5
Source File: TestGrid.java    From latexdraw with GNU General Public License v3.0 4 votes vote down vote up
@Theory
public void testGetSetGridDots(@TestedOn(ints = {0, 1, 10}) final int value) {
	shape.setGridDots(value);
	assertEquals(value, shape.getGridDots());
}
 
Example #6
Source File: TestStandardGridBase.java    From latexdraw with GNU General Public License v3.0 4 votes vote down vote up
@Theory
public void testGetSetLabelsSize(@StdGridData final StandardGrid shape, @TestedOn(ints = {0, 1, 10}) final int value) {
	shape.setLabelsSize(value);
	assertEquals(value, shape.getLabelsSize());
}
 
Example #7
Source File: TestModifiablePointsShapeBase.java    From latexdraw with GNU General Public License v3.0 4 votes vote down vote up
@Theory
public void testSetPoint2KO2(@ModifPtShapeData final ModifiablePointsShape shape,
							@TestedOn(ints = {-2, 10}) final int value) {
	assertFalse(shape.setPoint(0, 0, value));
}
 
Example #8
Source File: TestPlot.java    From latexdraw with GNU General Public License v3.0 4 votes vote down vote up
@Theory
public void testValidGetSetNbPlottedPointsKO(@TestedOn(ints = {1, 0, -1}) final int value) {
	shape.setNbPlottedPoints(10);
	shape.setNbPlottedPoints(value);
	assertEquals(10, shape.getNbPlottedPoints());
}
 
Example #9
Source File: TestPlot.java    From latexdraw with GNU General Public License v3.0 4 votes vote down vote up
@Theory
public void testValidGetSetNbPlottedPoints(@TestedOn(ints = {2, 10, 200}) final int value) {
	shape.setNbPlottedPoints(value);
	assertEquals(value, shape.getNbPlottedPoints());
}
 
Example #10
Source File: TestControlPointShapeBase.java    From latexdraw with GNU General Public License v3.0 4 votes vote down vote up
@Theory
public void testSetYSecondCtrlPt(@CtrlShapeData final ControlPointShape sh, @TestedOn(ints = {0, 1, -1}) final int index) {
	sh.setYSecondCtrlPt(33d, index);
	assertEqualsDouble(33d, sh.getSecondCtrlPtAt(index).getY());
}
 
Example #11
Source File: TestControlPointShapeBase.java    From latexdraw with GNU General Public License v3.0 4 votes vote down vote up
@Theory
public void testSetXSecondCtrlPt(@CtrlShapeData final ControlPointShape sh, @TestedOn(ints = {0, 1, -1}) final int index) {
	sh.setXSecondCtrlPt(33d, index);
	assertEqualsDouble(33d, sh.getSecondCtrlPtAt(index).getX());
}
 
Example #12
Source File: TestControlPointShapeBase.java    From latexdraw with GNU General Public License v3.0 4 votes vote down vote up
@Theory
public void testSetYFirstCtrlPt(@CtrlShapeData final ControlPointShape sh, @TestedOn(ints = {0, 1, -1}) final int index) {
	sh.setYFirstCtrlPt(33d, index);
	assertEqualsDouble(33d, sh.getFirstCtrlPtAt(index).getY());
}
 
Example #13
Source File: TestControlPointShapeBase.java    From latexdraw with GNU General Public License v3.0 4 votes vote down vote up
@Theory
public void testSetXFirstCtrlPt(@CtrlShapeData final ControlPointShape sh, @TestedOn(ints = {0, 1, -1}) final int index) {
	sh.setXFirstCtrlPt(33d, index);
	assertEqualsDouble(33d, sh.getFirstCtrlPtAt(index).getX());
}
 
Example #14
Source File: TestControlPointShapeBase.java    From latexdraw with GNU General Public License v3.0 4 votes vote down vote up
@Theory
public void testUpdateSecondControlPoints(@CtrlShapeData final ControlPointShape sh, @TestedOn(ints = {-2, 2}) final int value) {
	assertNull(sh.getSecondCtrlPtAt(value));
}
 
Example #15
Source File: TestControlPointShapeBase.java    From latexdraw with GNU General Public License v3.0 4 votes vote down vote up
@Theory
public void testGetSecondCtrlPtAt(@CtrlShapeData final ControlPointShape sh, @TestedOn(ints = {0, 1, -1}) final int value) {
	assertNotNull(sh.getSecondCtrlPtAt(value));
}
 
Example #16
Source File: TestControlPointShapeBase.java    From latexdraw with GNU General Public License v3.0 4 votes vote down vote up
@Theory
public void testGetFirstCtrlPtAtKO(@CtrlShapeData final ControlPointShape sh, @TestedOn(ints = {-2, 2}) final int value) {
	assertNull(sh.getFirstCtrlPtAt(value));
}
 
Example #17
Source File: TestControlPointShapeBase.java    From latexdraw with GNU General Public License v3.0 4 votes vote down vote up
@Theory
public void testGetFirstCtrlPtAt(@CtrlShapeData final ControlPointShape sh, @TestedOn(ints = {0, 1, -1}) final int value) {
	assertNotNull(sh.getFirstCtrlPtAt(value));
}
 
Example #18
Source File: TestFreehand.java    From latexdraw with GNU General Public License v3.0 4 votes vote down vote up
@Theory
public void testGetSetInterval(@TestedOn(ints = {1, 10}) final int value) {
	shape.setInterval(value);
	assertEquals(value, shape.getInterval());
}
 
Example #19
Source File: TestRectangularShapeBase.java    From latexdraw with GNU General Public License v3.0 4 votes vote down vote up
@Theory
public void testGetPtAtKO(@RectangularData final RectangularShape shape, @TestedOn(ints = {-2, 4}) final int i) {
	assertNull(shape.getPtAt(i));
}
 
Example #20
Source File: TestRectangularShapeBase.java    From latexdraw with GNU General Public License v3.0 4 votes vote down vote up
@Theory
public void testGetPtAt(@RectangularData final RectangularShape shape, @TestedOn(ints = {-1, 0, 1, 2, 3}) final int i) {
	assertNotNull(shape.getPtAt(i));
}
 
Example #21
Source File: TestSetShapesBase.java    From latexdraw with GNU General Public License v3.0 4 votes vote down vote up
@Theory
public void testRemoveShapeIntKO(@SetShapeData final SetShapesProp shape, @TestedOn(ints = {-2, -1, 1, 2}) final int value) {
	shape.getShapes().add(sh1);
	shape.removeShape(value);
}
 
Example #22
Source File: DeploymentGroupTest.java    From helios with Apache License 2.0 4 votes vote down vote up
@Theory
public void testStopDeploymentGroup(
    @TestedOn(ints = { 0, 1 }) final int dgExistsInt,
    @TestedOn(ints = { 0, 1 }) final int tasksExistInt,
    @TestedOn(ints = { 0, 1 }) final int tasksExistWhenCommittingInt
) throws Exception {
  final boolean dgExists = dgExistsInt != 0;
  final boolean tasksExist = tasksExistInt != 0;
  final boolean tasksExistWhenCommitting = tasksExistWhenCommittingInt != 0;

  // To be able to simulate triggering the race condition in stopDeploymentGroup we need to do
  // some mocking, relying on that the implementation uses client.exists() to check for the
  // presence of tasks.
  final ZooKeeperClient client = spy(this.client);
  when(client.exists(Paths.statusDeploymentGroupTasks(GROUP_NAME)))
      .thenReturn(tasksExist ? mock(Stat.class) : null);

  final ZooKeeperMasterModel masterModel = newMasterModel(client);

  if (dgExists) {
    final DeploymentGroup dg = DeploymentGroup.newBuilder()
        .setName(GROUP_NAME)
        .build();
    masterModel.addDeploymentGroup(dg);
  }

  if (tasksExistWhenCommitting) {
    client.ensurePath(Paths.statusDeploymentGroupTasks());
    client.create(Paths.statusDeploymentGroupTasks(GROUP_NAME));
  }

  if (!dgExists) {
    exception.expect(DeploymentGroupDoesNotExistException.class);
  } else if (tasksExist != tasksExistWhenCommitting) {
    exception.expect(HeliosRuntimeException.class);
  }

  masterModel.stopDeploymentGroup(GROUP_NAME);

  // Verify that the state in ZK is correct:
  // * tasks are not present
  // * the status is set to FAILED
  //
  // When checking for the existence of the tasks make sure we use the client that doesn't have
  // the exists() method mocked out!
  assertNull(this.client.exists(Paths.statusDeploymentGroupTasks(GROUP_NAME)));
  final DeploymentGroupStatus status = masterModel.getDeploymentGroupStatus(GROUP_NAME);
  assertEquals(FAILED, status.getState());
}