Esempio n. 1
0
 private static Input.Builder createTextAreaInput(final String name, final String label) {
   return Input.create()
       .inputType(InputTypeName.TEXT_AREA)
       .label(label)
       .name(name)
       .immutable(true);
 }
Esempio n. 2
0
  @Test
  public final void test_get_mixin() throws Exception {
    Mixin mixin =
        Mixin.create()
            .createdTime(LocalDateTime.of(2013, 1, 1, 12, 0, 0).toInstant(ZoneOffset.UTC))
            .name(MY_MIXIN_QUALIFIED_NAME_1.toString())
            .addFormItem(
                Input.create()
                    .name(MY_MIXIN_INPUT_NAME_1)
                    .inputType(InputTypeName.TEXT_LINE)
                    .label("Line Text 1")
                    .required(true)
                    .helpText("Help text line 1")
                    .required(true)
                    .build())
            .build();

    Mockito.when(mixinService.getByName(Mockito.isA(MixinName.class))).thenReturn(mixin);

    String response =
        request()
            .path("schema/mixin")
            .queryParam("name", MY_MIXIN_QUALIFIED_NAME_1.toString())
            .get()
            .getAsString();

    assertJson("get_mixin.json", response);
  }
Esempio n. 3
0
  @Test
  public void testMixinIcon() throws Exception {
    byte[] data = Resources.toByteArray(getClass().getResource("mixinicon.png"));
    final Icon icon = Icon.from(data, "image/png", Instant.now());

    Mixin mixin =
        Mixin.create()
            .name("myapplication:postal_code")
            .displayName("My content type")
            .icon(icon)
            .addFormItem(
                Input.create()
                    .name("postal_code")
                    .label("Postal code")
                    .inputType(InputTypeName.TEXT_LINE)
                    .build())
            .build();
    setupMixin(mixin);

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

    // verify
    assertImage(mixinIcon, 20);
  }
Esempio n. 4
0
  @Test
  public final void test_list_mixins() throws Exception {
    Mixin mixin1 =
        Mixin.create()
            .createdTime(LocalDateTime.of(2013, 1, 1, 12, 0, 0).toInstant(ZoneOffset.UTC))
            .name(MY_MIXIN_QUALIFIED_NAME_1.toString())
            .addFormItem(
                Input.create()
                    .name(MY_MIXIN_INPUT_NAME_1)
                    .inputType(InputTypeName.TEXT_LINE)
                    .label("Line Text 1")
                    .required(true)
                    .helpText("Help text line 1")
                    .required(true)
                    .build())
            .build();

    Mixin mixin2 =
        Mixin.create()
            .createdTime(LocalDateTime.of(2013, 1, 1, 12, 0, 0).toInstant(ZoneOffset.UTC))
            .name(MY_MIXIN_QUALIFIED_NAME_2.toString())
            .addFormItem(
                Input.create()
                    .name(MY_MIXIN_INPUT_NAME_2)
                    .inputType(InputTypeName.TEXT_AREA)
                    .label("Text Area")
                    .required(true)
                    .helpText("Help text area")
                    .required(true)
                    .build())
            .build();

    Mockito.when(mixinService.getAll()).thenReturn(Mixins.from(mixin1, mixin2));

    String result = request().path("schema/mixin/list").get().getAsString();

    assertJson("list_mixins.json", result);
  }
Esempio n. 5
0
  @Test
  public void testMixinIcon_default_image() throws Exception {
    Mixin mixin =
        Mixin.create()
            .name("myapplication:postal_code")
            .displayName("My content type")
            .addFormItem(
                Input.create()
                    .name("postal_code")
                    .label("Postal code")
                    .inputType(InputTypeName.TEXT_LINE)
                    .build())
            .build();
    setupMixin(mixin);

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

    // verify
    assertImage(mixinIcon, 20);
  }