// Returns are randomly generated email id, part before the domain name
  private String shuffleEmail(String email) {

    String shuffledString = "";

    while (email.length() != 0) {
      int index = (int) Math.floor(Math.random() * email.length());
      char c = email.charAt(index);
      email = email.substring(0, index) + email.substring(index + 1);
      shuffledString += c;
    }

    return shuffledString;
  }
Example #2
0
  // Note this is a bit of a integration test not a strict unit test
  @Test
  public void testFillingAMoreComplicatedBoundingRectangle() throws Exception {
    double xStart = 0.0;
    double xStop = 25.5;
    double yStart = 0.0;
    double yStop = 33.33;

    double xStep = 0.4;
    double yStep = 0.6;

    RectangularROI roi = new RectangularROI();
    roi.setPoint(Math.min(xStart, xStop), Math.min(yStart, yStop));
    roi.setLengths(Math.abs(xStop - xStart), Math.abs(yStop - yStart));

    RasterModel model = new RasterModel();
    model.setxStep(xStep);
    model.setyStep(yStep);

    // Get the point list
    IPointGenerator<RasterModel, Point> gen = service.createGenerator(model, roi);
    List<Point> pointList = gen.createPoints();

    int rows = (int) (Math.floor((xStop - xStart) / xStep) + 1);
    int cols = (int) (Math.floor((yStop - yStart) / yStep) + 1);
    // Check the list size
    assertEquals("Point list size should be correct", rows * cols, pointList.size());

    // Check some points
    assertEquals(new Point(0, xStart, 0, yStart), pointList.get(0));
    assertEquals(xStart + 3 * xStep, pointList.get(3).getX(), 1e-8);
    // TODO more

    GeneratorUtil.testGeneratorPoints(gen);
  }
 @Override
 public void describeTo(Description desc) {
   if (expected == null || actual == null) {
     desc.appendValue(expected);
   } else {
     int lines = Math.min(expectedLines.size(), actualLines.size());
     for (int idx = 0; idx < lines; idx++) {
       String expectedLine = expectedLines.get(idx);
       String actualLine = actualLines.get(idx);
       if (!expectedLine.equals(actualLine)) {
         desc.appendValue(expectedLine);
         desc.appendText(", but actual is ");
         desc.appendValue(actualLine);
         desc.appendText(", line " + (idx + 1) + "\n");
         desc.appendValue(expected);
         return;
       }
     }
     desc.appendText("expected text is " + expectedLines.size() + " lines, ");
     desc.appendText("but actual text is " + actualLines.size() + " lines\n");
     desc.appendValue(expected);
   }
 }
 @Test(timeout = 500)
 public void testSlowFactorial5() throws Exception {
   final Math math = new Math();
   assertThat("Addition", math.slowFactorial(5), is(BigInteger.valueOf(120)));
 }