コード例 #1
0
  @Test
  public void testList() throws Exception {
    final RelationshipType relationshipType1 =
        RelationshipType.create().name("myapplication:the_relationship_type_1").build();

    final RelationshipType relationshipType2 =
        RelationshipType.create().name("myapplication:the_relationship_type_2").build();

    final RelationshipTypes relationshipTypes =
        RelationshipTypes.from(relationshipType1, relationshipType2);
    Mockito.when(relationshipTypeService.getAll()).thenReturn(relationshipTypes);

    String response = request().path("schema/relationship/list").get().getAsString();

    assertJson("get_relationship_type_list.json", response);
  }
コード例 #2
0
  @Test
  public void testRelationshipTypeIcon_default_image() throws Exception {
    RelationshipType relationshipType =
        RelationshipType.create()
            .name("myapplication:like")
            .fromSemantic("likes")
            .toSemantic("liked by")
            .addAllowedFromType(ContentTypeName.from("myapplication:person"))
            .addAllowedToType(ContentTypeName.from("myapplication:person"))
            .build();
    setupRelationshipType(relationshipType);

    // exercise
    final Response response = this.resource.getIcon("myapplication:like", 20, null);
    final BufferedImage mixinIcon = (BufferedImage) response.getEntity();

    // verify
    assertImage(mixinIcon, 20);
  }
コード例 #3
0
  @Test
  public void testRequestGetRelationshipTypeJson_existing() throws Exception {
    final RelationshipType relationshipType =
        RelationshipType.create()
            .name("myapplication:the_relationship_type")
            .description("RT description")
            .build();

    final RelationshipTypeName name =
        RelationshipTypeName.from("myapplication:the_relationship_type");
    Mockito.when(relationshipTypeService.getByName(name)).thenReturn(relationshipType);

    String response =
        request()
            .path("schema/relationship")
            .queryParam("name", "myapplication:the_relationship_type")
            .get()
            .getAsString();

    assertJson("get_relationship_type.json", response);
  }
コード例 #4
0
  @Test
  public void testRelationshipTypeIcon() throws Exception {
    byte[] data = Resources.toByteArray(getClass().getResource("relationshipicon.png"));
    final Icon icon = Icon.from(data, "image/png", Instant.now());

    RelationshipType relationshipType =
        RelationshipType.create()
            .name("myapplication:like")
            .fromSemantic("likes")
            .toSemantic("liked by")
            .addAllowedFromType(ContentTypeName.from("myapplication:person"))
            .addAllowedToType(ContentTypeName.from("myapplication:person"))
            .icon(icon)
            .build();
    setupRelationshipType(relationshipType);

    // exercise
    final Response response = this.resource.getIcon("myapplication:like", 20, null);
    final BufferedImage mixinIcon = (BufferedImage) response.getEntity();

    // verify
    assertImage(mixinIcon, 20);
  }
コード例 #5
0
 private void setupRelationshipType(final RelationshipType relationshipType) {
   Mockito.when(relationshipTypeService.getByName(relationshipType.getName()))
       .thenReturn(relationshipType);
 }