Ejemplo n.º 1
0
  @Test
  public void add_properties_then_index_document_items_created_for_each_property()
      throws Exception {
    RootDataSet rootDataSet = new RootDataSet();
    rootDataSet.addProperty(DataPath.from("a.b.c"), Value.newDouble(2.0));
    rootDataSet.setProperty(DataPath.from("a.b.d"), Value.newLocalDate(LocalDate.now()));

    Node node = Node.newNode().id(EntityId.from("myId")).rootDataSet(rootDataSet).build();

    final Collection<IndexDocument> indexDocuments =
        NodeIndexDocumentFactory.create(node, TEST_WORKSPACE);

    final IndexDocument indexDocument = getIndexDocumentOfType(indexDocuments, IndexType.NODE);

    assertNotNull(
        getItemWithName(indexDocument, IndexDocumentItemPath.from("a_b_c"), IndexValueType.NUMBER));
    assertNotNull(
        getItemWithName(
            indexDocument, IndexDocumentItemPath.from("a_b_d"), IndexValueType.DATETIME));
  }
Ejemplo n.º 2
0
  public AbstractIndexDocumentItem getItemWithName(
      final IndexDocument indexDocument,
      final IndexDocumentItemPath path,
      final IndexValueType baseType) {
    for (AbstractIndexDocumentItem item : indexDocument.getIndexDocumentItems()) {
      if (item.getPath().equals(path.toString()) && item.getIndexBaseType().equals(baseType)) {
        return item;
      }
    }

    return null;
  }
Ejemplo n.º 3
0
  public Set<AbstractIndexDocumentItem> getItemsWithName(
      final IndexDocument indexDocument,
      final IndexDocumentItemPath path,
      final IndexValueType baseType) {
    Set<AbstractIndexDocumentItem> items = Sets.newHashSet();

    for (AbstractIndexDocumentItem item : indexDocument.getIndexDocumentItems()) {
      if (item.getPath().equals(path.toString()) && item.getIndexBaseType().equals(baseType)) {
        items.add(item);
      }
    }

    return items;
  }
Ejemplo n.º 4
0
  @Test
  public void create_for_properties_with_multiple_values() throws Exception {
    RootDataSet rootDataSet = new RootDataSet();
    rootDataSet.addProperty(DataPath.from("a.b.c"), Value.newDouble(2.0));
    rootDataSet.addProperty(DataPath.from("a.b.c"), Value.newDouble(3.0));

    Node node = Node.newNode().id(EntityId.from("myId")).rootDataSet(rootDataSet).build();

    final Collection<IndexDocument> indexDocuments =
        NodeIndexDocumentFactory.create(node, TEST_WORKSPACE);

    assertTrue(indexDocuments.iterator().hasNext());
    final IndexDocument next = indexDocuments.iterator().next();

    final Set<AbstractIndexDocumentItem> numberItems =
        getItemsWithName(next, IndexDocumentItemPath.from("a_b_c"), IndexValueType.NUMBER);

    assertEquals(2, numberItems.size());
  }