Ejemplo n.º 1
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);
  }
Ejemplo n.º 2
0
  @Test
  public final void test_get_mixin_not_found() throws Exception {
    Mockito.when(mixinService.getByName(Mockito.any(MixinName.class))).thenReturn(null);

    final MockRestResponse response =
        request()
            .path("schema/mixin")
            .queryParam("name", MY_MIXIN_QUALIFIED_NAME_1.toString())
            .get();
    Assert.assertEquals(404, response.getStatus());
  }
Ejemplo n.º 3
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);
  }
Ejemplo n.º 4
0
 private void setupMixin(final Mixin mixin) {
   Mockito.when(mixinService.getByName(mixin.getName())).thenReturn(mixin);
 }