public void testChangeCompression() throws NimbitsException {
    Point p = PointModelFactory.createPointModel(null);

    EntityName name =
        (CommonFactoryLocator.getInstance()
            .createName("test" + UUID.randomUUID().toString(), EntityType.point));
    p.setFilterValue(0.0);
    ClientHelper.client().addPoint(name, p);

    Point px = ClientHelper.client().getPoint(name);

    Assert.assertNotNull(px);
    px.setFilterValue(2.0);
    ClientHelper.client().updatePoint(px);

    Point px2 = ClientHelper.client().getPoint(name);
    Assert.assertEquals(2.0, px2.getFilterValue());
    Assert.assertEquals(px.getKey(), px2.getKey());
    try {
      Thread.sleep(1000);
    } catch (InterruptedException e) {
      fail();
    }
    // double x2 = testCompression(p);
    ClientHelper.client().deletePoint(name);
    // Assert.assertEquals(255.0, x2);

    // gClient.DeletePoint(p.getValue());
  }
示例#2
0
  private Point createFeedPoint(final User user) throws NimbitsException {

    final EntityName name =
        CommonFactoryLocator.getInstance().createName(Const.TEXT_DATA_FEED, EntityType.point);

    final Entity entity =
        EntityModelFactory.createEntity(
            name,
            "",
            EntityType.feed,
            ProtectionLevel.onlyConnection,
            user.getKey(),
            user.getKey(),
            UUID.randomUUID().toString());
    // final Entity r = EntityServiceFactory.getInstance().addUpdateEntity(user, entity);

    Point point = PointModelFactory.createPointModel(entity);

    final Point result = (Point) EntityServiceFactory.getInstance().addUpdateEntity(point);

    postToFeed(
        user,
        "A new data point has been created for your data feed. Your data feed is just "
            + "a data point. Points are capable of storing numbers, text, json and xml data. Nimbits uses "
            + "a single data point to drive this feed.",
        FeedType.info);
    return result;
  }
  public void testCompressionSeperateAlternatingValuesPostsNoDate() throws Exception {

    Point p = PointModelFactory.createPointModel(null);

    EntityName name =
        (CommonFactoryLocator.getInstance()
            .createName("test" + UUID.randomUUID().toString(), EntityType.point));
    p.setFilterValue(0.1);
    Point result = ClientHelper.client().addPoint(name);
    assertNotNull(result);

    double rx = 0.0;

    try {

      for (int i = 0; i < 40; i++) {
        StringBuilder b = new StringBuilder();
        if (rx == 0.0) {
          rx = 1.0;
        } else {
          rx = 0.0;
        }

        b.append("&p2=")
            .append(URLEncoder.encode(name.getValue(), Const.CONST_ENCODING))
            .append("&v2=")
            .append(rx);
        // System.out.println( b.toString());
        System.out.println(ClientHelper.client().recordBatch(b.toString()));
        Thread.sleep(100);
      }
      Thread.sleep(3000);
      List<Value> v = ClientHelper.client().getSeries(name, 40);
      double retVal = 0.0;
      for (Value x : v) {
        retVal += x.getDoubleValue();
      }

      DecimalFormat twoDForm = new DecimalFormat("#.##");
      retVal = Double.valueOf(twoDForm.format(retVal));
      ClientHelper.client().deletePoint(name);
      Assert.assertEquals(20.0, retVal);

    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
  @Test
  public void testCompression() throws NimbitsException {
    Point p = PointModelFactory.createPointModel(null);

    EntityName name =
        (CommonFactoryLocator.getInstance().createName("test" + UUID.randomUUID().toString()));
    p.setFilterValue(2.0);
    Point result = ClientHelper.client().addPoint(name, p);
    assertNotNull(result);
    Point test = ClientHelper.client().getPoint(name);
    assertNotNull(test);
    double x = testCompression(name);

    // Assert.assertEquals(255.0, x);
    // ClientHelper.client().deletePoint(p.getName());
  }
  public void testCompressionSeparatePostsNoDate() throws Exception {
    Point p = PointModelFactory.createPointModel(null);
    EntityName name =
        (CommonFactoryLocator.getInstance()
            .createName("test" + UUID.randomUUID().toString(), EntityType.point));
    p.setFilterValue(0.1);
    ClientHelper.client().addPoint(name);

    double rx = 0.0;

    try {

      for (int i = 0; i < 40; i++) {
        StringBuilder b = new StringBuilder();
        rx += 0.1;

        b.append("&p1=")
            .append(URLEncoder.encode(name.getValue(), Const.CONST_ENCODING))
            .append("&v1=")
            .append(rx);
        // System.out.println( b.toString());
        ClientHelper.client().recordBatch(b.toString());
        System.out.println(rx);
        Thread.sleep(1000);
      }

      Thread.sleep(2000);
      List<Value> v = ClientHelper.client().getSeries(name.getValue(), 10);
      double retVal = 0.0;
      for (Value x : v) {
        retVal += x.getDoubleValue();
        System.out.println(x.getDoubleValue());
      }

      DecimalFormat twoDForm = new DecimalFormat("#.##");
      retVal = Double.valueOf(twoDForm.format(retVal));
      ClientHelper.client().deletePoint(name.getValue());

      assertEquals(30.0, retVal, 0.0);

    } catch (IOException e) {

    } catch (InterruptedException e) {

    }
  }
  public void testNoCompression() throws Exception {
    final Point p = PointModelFactory.createPointModel(null);
    final EntityName name =
        CommonFactoryLocator.getInstance()
            .createName("test" + UUID.randomUUID().toString(), EntityType.point);
    p.setExpire(1);
    p.setFilterValue(0);
    final Point point = ClientHelper.client().addPoint(name, p);
    assertNotNull(point);

    final double x = testCompression(name);
    ClientHelper.client().deletePoint(name);

    Assert.assertEquals(345.0, x);

    //   gClient.DeletePoint(p.getValue());
  }
示例#7
0
    @Override
    public void handleEvent(MessageBoxEvent be) {
      final String email = be.getValue();
      if (email != null) {
        if (!email.isEmpty()) {
          UserServiceAsync userService = GWT.create(UserService.class);
          try {
            EmailAddress emailAddress =
                CommonFactoryLocator.getInstance().createEmailAddress(email);

            userService.sendConnectionRequest(emailAddress, new ConnectionRequestAsyncCallback());
          } catch (NimbitsException e) {
            FeedbackHelper.showError(e);
          }
        }
      }
    }
示例#8
0
    @Override
    public void handleEvent(final MessageBoxEvent be) {
      final String newEntityName = be.getValue();
      if (!Utils.isEmptyString(newEntityName)) {
        final EntityName categoryName;
        try {
          categoryName =
              CommonFactoryLocator.getInstance().createName(newEntityName, EntityType.category);
        } catch (NimbitsException e) {
          FeedbackHelper.showError(e);
          return;
        }

        final EntityServiceAsync service = GWT.create(EntityService.class);
        Entity entity = EntityModelFactory.createEntity(categoryName, EntityType.category);

        service.addUpdateEntity(entity, new AddUpdateEntityAsyncCallback());
      }
    }
  public void TestZeroCompressionWithBatch() throws NimbitsException {
    Point p = PointModelFactory.createPointModel(null);

    EntityName name =
        (CommonFactoryLocator.getInstance()
            .createName("test" + UUID.randomUUID().toString(), EntityType.point));
    p.setFilterValue(0.0);
    ClientHelper.client().addPoint(name, p);
    System.out.println(
        "Starting batch compression integration test compression = " + p.getFilterValue());

    StringBuilder b = new StringBuilder();

    try {

      for (int i = 0; i < 40; i++) {
        b.append("&p")
            .append(i)
            .append("=")
            .append(URLEncoder.encode(name.getValue(), Const.CONST_ENCODING))
            .append("&v")
            .append(i)
            .append("=")
            .append(i)
            .append("&t")
            .append(i)
            .append("=")
            .append(new Date().getTime());

        Thread.sleep(100);
      }
      System.out.println(b.toString());
      System.out.println(ClientHelper.client().recordBatch(b.toString()));

      double retVal = 0.0;

      Thread.sleep(1000);
      List<Value> v = ClientHelper.client().getSeries(name, 10);
      for (Value x : v) {
        retVal += x.getDoubleValue();
        System.out.println(x.getDoubleValue() + "  " + x.getTimestamp());
      }
      Assert.assertEquals(345.0, retVal);
      ClientHelper.client().deletePoint(name);
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (InterruptedException e) {
      e.printStackTrace(); // To change body of catch statement use File | Settings | File
      // Templates.
    }

    //				String ba = "&email=" + email + "&secret="  + secret +
    //				"&p1=" + URLEncoder.encode("b1", Const.CONST_ENCODING)+ "&v1=" + r.nextDouble() +
    //				"&p2=" + URLEncoder.encode("b2", Const.CONST_ENCODING)+ "&v2=" + r.nextDouble() +
    //				"&p3=" + URLEncoder.encode("b3", Const.CONST_ENCODING)+ "&v3=" + r.nextDouble() +
    //				"&p4=" + URLEncoder.encode("b4", Const.CONST_ENCODING)+ "&v4=" + r.nextDouble() +
    //				"&p5=" + URLEncoder.encode("b5", Const.CONST_ENCODING)+ "&v5=" + r.nextDouble() +
    //				"&p6=" + URLEncoder.encode("b6", Const.CONST_ENCODING)+ "&v6=" + r.nextDouble() +
    //				"&p7=" + URLEncoder.encode("b7", Const.CONST_ENCODING)+ "&v7=" + r.nextDouble();
    //
    //
  }