Exemplo n.º 1
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);
  }
Exemplo n.º 2
0
  // 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;
  }