Пример #1
0
  /** Get all constraints. */
  @SuppressWarnings("unchecked")
  @Documented
  @Test
  @GraphDescription.Graph(nodes = {})
  public void get_constraints() throws PropertyValueException {
    data.get();

    String labelName1 = "user", propertyKey1 = "name1";
    String labelName2 = "prog", propertyKey2 = "name2";
    createLabelUniquenessPropertyConstraint(labelName1, propertyKey1);
    createLabelUniquenessPropertyConstraint(labelName2, propertyKey2);

    String result = gen.get().noGraph().expectedStatus(200).get(getSchemaConstraintUri()).entity();

    List<Map<String, Object>> serializedList = jsonToList(result);

    assertEquals(2, serializedList.size());

    Map<String, Object> serialized1 = serializedList.get(0);
    assertEquals(labelName1, serialized1.get("label"));
    assertEquals(ConstraintType.UNIQUENESS.name(), serialized1.get("type"));
    List<String> keyList1 = (List<String>) serialized1.get("property_keys");

    Map<String, Object> serialized2 = serializedList.get(1);
    assertEquals(labelName2, serialized2.get("label"));
    assertEquals(ConstraintType.UNIQUENESS.name(), serialized2.get("type"));
    List<String> keyList2 = (List<String>) serialized2.get("property_keys");

    assertEquals(asSet(asList(propertyKey1), asList(propertyKey2)), asSet(keyList1, keyList2));
  }
Пример #2
0
  /** Create uniqueness constraint. Create a uniqueness constraint on a property. */
  @Documented
  @Test
  @GraphDescription.Graph(nodes = {})
  public void createPropertyUniquenessConstraint() throws PropertyValueException {
    data.get();

    String labelName = "person", propertyKey = "name";
    Map<String, Object> definition = map("property_keys", asList(propertyKey));

    String result =
        gen.get()
            .noGraph()
            .expectedStatus(200)
            .payload(createJsonFrom(definition))
            .post(getSchemaConstraintLabelUniquenessUri(labelName))
            .entity();

    Map<String, Object> serialized = jsonToMap(result);
    assertEquals(labelName, serialized.get("label"));
    assertEquals(ConstraintType.UNIQUENESS.name(), serialized.get("type"));
    assertEquals(asList(propertyKey), serialized.get("property_keys"));
  }
Пример #3
0
  /**
   * Get a specific uniqueness constraint. Get a specific uniqueness constraint for a label and a
   * property.
   */
  @Documented
  @Test
  @GraphDescription.Graph(nodes = {})
  public void getLabelUniquenessPropertyConstraint() throws PropertyValueException {
    data.get();

    String labelName = "user", propertyKey = "name";
    createLabelUniquenessPropertyConstraint(labelName, propertyKey);

    String result =
        gen.get()
            .noGraph()
            .expectedStatus(200)
            .get(getSchemaConstraintLabelUniquenessPropertyUri(labelName, propertyKey))
            .entity();

    List<Map<String, Object>> serializedList = jsonToList(result);
    assertEquals(1, serializedList.size());
    Map<String, Object> serialized = serializedList.get(0);
    assertEquals(labelName, serialized.get("label"));
    assertEquals(ConstraintType.UNIQUENESS.name(), serialized.get("type"));
    assertEquals(asList(propertyKey), serialized.get("property_keys"));
  }