@Test public void bindResourceIsDeserializedFromJson() { BindResource bindResource = JsonUtils.readTestDataFile("bindResource.json", BindResource.class); assertThat(bindResource.getAppGuid()).isEqualTo("test-app-guid"); assertThat(bindResource.getRoute()).isEqualTo("http://test.example.com"); assertThat(bindResource.getProperties()).hasSize(3); assertThat(bindResource.getProperty("property1")).isEqualTo(1); assertThat(bindResource.getProperty("property2")).isEqualTo("value2"); assertThat(bindResource.getProperty("property3")).isEqualTo(true); }
@Test @SuppressWarnings("serial") public void bindResourceIsBuiltWithAllValues() { Map<String, Object> parameters = new HashMap<String, Object>() {{ put("parameter3", "value3"); put("parameter4", true); }}; BindResource bindResource = BindResource.builder() .appGuid("app-guid") .route("route") .properties("parameter1", "value1") .properties("parameter2", 2) .properties(parameters) .build(); assertThat(bindResource.getAppGuid()).isEqualTo("app-guid"); assertThat(bindResource.getRoute()).isEqualTo("route"); assertThat(bindResource.getProperties()).hasSize(4); assertThat(bindResource.getProperties().get("parameter1")).isEqualTo("value1"); assertThat(bindResource.getProperties().get("parameter2")).isEqualTo(2); assertThat(bindResource.getProperties().get("parameter3")).isEqualTo("value3"); assertThat(bindResource.getProperties().get("parameter4")).isEqualTo(true); }
@Test public void bindResourceIsBuiltWithDefaults() { BindResource bindResource = BindResource.builder() .build(); assertThat(bindResource.getAppGuid()).isNull(); assertThat(bindResource.getRoute()).isNull(); assertThat(bindResource.getProperties()).isEmpty(); }