@Test public void getJdbcProperties() throws java.io.IOException { // when Response response = given().accept(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .expect().statusCode(200).log().ifError() // .get(getVersionPrefix() + "/properties/{definitionName}", DATA_STORE_DEFINITION_NAME); // then ObjectNode jdbcProperties = mapper.readerFor(ObjectNode.class).readValue(response.asInputStream()); // should resemble jdbc_data_store_form.json assertNotNull(jdbcProperties.get("jsonSchema")); assertNotNull(jdbcProperties.get("properties")); assertNotNull(jdbcProperties.get("uiSchema")); assertEquals("JDBCDatastore", jdbcProperties.get("properties").get("@definitionName").textValue()); }
private String getDataStoreDefinitionPropertiesTitle(Locale locale) throws IOException { Response response = given().accept(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .expect() // .statusCode(200).log().ifError() // .with().port(localServerPort) // .param(LANGUAGE_QUERY_PARAMETER_NAME, locale.toLanguageTag()) .get(getVersionPrefix() + "/properties/{name}", DATA_STORE_DEFINITION_NAME); JsonNode jsonNode = mapper.readTree(response.asInputStream()); return jsonNode.get("jsonSchema").get("title").asText(); }
@Test public void testGetVersion() throws Exception { Response r = given().accept(APPLICATION_JSON_UTF8_VALUE) // .expect() // .statusCode(200).log().ifError() // .with().port(localServerPort) // .get(getVersionPrefix() + "/version"); r.then() // .statusCode(HttpStatus.OK.value()).log().ifError() // .contentType(APPLICATION_JSON_UTF8_VALUE); // We don't care what values are returned as long as they are filled. JsonPath jsonPathEvaluator = r.jsonPath(); assertThat(jsonPathEvaluator.get("version"), allOf(notNullValue(), not(equalTo(VersionDto.N_A)))); assertThat(jsonPathEvaluator.get("commit"), allOf(notNullValue(), not(equalTo(VersionDto.N_A)))); assertThat(jsonPathEvaluator.get("time"), allOf(notNullValue(), not(equalTo(VersionDto.N_A)))); } }
protected static void assertCreateUser(User user){ given() .contentType("application/json;charset=UTF-8") .accept("application/json") .body(user) .expect().log().ifError() .statusCode(HttpStatus.SC_CREATED) .when() .post(getHost() + CONTEXT_PATH + "/users"); }
protected static UserDTO assertUserExists(String path){ Response response = given() .expect().log().ifError() .statusCode(HttpStatus.SC_OK) .when() .get(getHost() + CONTEXT_PATH + path + JSON_SUFFIX); return deserialize(response.getBody().asString()); } }
@Test public void testGetIcon_svgImageTypeFound() throws Exception { given().expect() // .statusCode(200).log().ifError() // .body(Matchers.containsString("</svg>")) // .contentType(IMAGE_SVG_VALUE) // .get(getVersionPrefix() + "/properties/{name}/icon/{type}", DATA_SET_DEFINITION_NAME, DefinitionImageType.SVG_ICON); }
@Test public void initializeFullExampleDatasetProperties() throws java.io.IOException { SerPropertiesDto serPropertiesDto = createDatasetDatastoreSerPropertiesDto(); given().content(serPropertiesDto).contentType(ServiceConstants.JSONIO_CONTENT_TYPE) // .accept(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .expect().statusCode(200).log().ifError() // .when()// .post(getVersionPrefix() + "/properties/uispec")// .then()// .body("jsonSchema", notNullValue())// .body("properties", notNullValue())// .body("uiSchema", notNullValue())// .body("properties.@definitionName", equalTo("FullExampleDataset"))// .body("uiSchema.moduleName.'ui:widget'", equalTo("hidden"))// .body("uiSchema.query.'ui:widget'", equalTo("textarea"))// ; }
@Test public void testAfterDatastoreCalled() throws java.io.IOException { SerPropertiesDto serPropertiesDto = createDatasetDatastoreSerPropertiesDto(); given().content(serPropertiesDto).contentType(ServiceConstants.JSONIO_CONTENT_TYPE) // .accept(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .expect().statusCode(200).log().ifError() // .when()// .post(getVersionPrefix() + "/properties/uispec")// .then()// .body("jsonSchema", notNullValue())// .body("properties", notNullValue())// .body("uiSchema", notNullValue())// .body("properties.testAfterDatastoreTrigger", equalTo("bar"))// ; }
@Test public void testValidateProperties() throws Exception { ObjectNode validationResult = given().accept(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .expect() // .statusCode(200).log().ifError() // .with() // .content(buildTestDataStoreFormData()) // .contentType(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .post(getVersionPrefix() + "/properties/validate").as(ObjectNode.class); assertNotNull(validationResult); assertEquals("OK", validationResult.get("status").textValue()); }
@Test public void testValidatePropertiesJsonio() throws Exception { ObjectNode validationResult = given().accept(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .expect() // .statusCode(200).log().ifError() // .with() // .content(buildTestDataStoreSerProps()) // .contentType(ServiceConstants.JSONIO_CONTENT_TYPE) // .post(getVersionPrefix() + "/properties/validate").as(ObjectNode.class); assertNotNull(validationResult); assertEquals("OK", validationResult.get("status").textValue()); }
@Test public void getJdbcDataSetProperties() throws java.io.IOException { // given UiSpecsPropertiesDto properties = new UiSpecsPropertiesDto(); properties.setProperties(getJdbcDataStoreProperties()); // when Response response = given().content(properties).contentType(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .accept(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .expect().statusCode(200).log().ifError() // .post(getVersionPrefix() + "/properties/dataset"); // then ObjectNode dataSetProperties = mapper.readerFor(ObjectNode.class).readValue(response.asInputStream()); assertNotNull(dataSetProperties); }
@Test public void initializeFullExampleDatastoreProperties() throws java.io.IOException { SerPropertiesDto serProperties = new SerPropertiesDto(); serProperties.setProperties(new FullExampleDatastoreProperties("").init().toSerialized()); given().content(serProperties).contentType(ServiceConstants.JSONIO_CONTENT_TYPE) // .accept(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .expect().statusCode(200).log().ifError() // .when()// .post(getVersionPrefix() + "/properties/uispec")// .then()// .body("jsonSchema", notNullValue())// .body("properties", notNullValue())// .body("uiSchema", notNullValue())// .body("properties.@definitionName", equalTo("FullExampleDatastore"))// ; }
@Test public void testGetIcon_pngImageTypeFound() throws Exception { given().expect() // .contentType(IMAGE_PNG_VALUE) // .body(Matchers.startsWith("\uFFFDPNG")) // Magic header for PNG files. .statusCode(200).log().ifError() // .get(getVersionPrefix() + "/properties/{name}/icon/{type}", DATA_STORE_DEFINITION_NAME, DefinitionImageType.PALETTE_ICON_32X32); }
@Test public void testGetProperties() throws Exception { given().accept(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .expect() // .statusCode(200).log().ifError() // .with().port(localServerPort) // .get(getVersionPrefix() + "/properties/{name}", DATA_STORE_DEFINITION_NAME); }
@Test public void testGetDatasetPropertiesFromUiSpecs() throws Exception { given().accept(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .expect() // .statusCode(200).log().ifError() // .with() // .content(buildTestDataStoreFormData()) // .contentType(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .post(getVersionPrefix() + "/properties/dataset"); }
@Test public void testGetDatasetPropertiesFromSer() throws Exception { given().accept(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .expect() // .statusCode(200).log().ifError() // .with() // .content(buildTestDataStoreSerProps()) // .contentType(ServiceConstants.JSONIO_CONTENT_TYPE) // .post(getVersionPrefix() + "/properties/dataset"); }
@Test public void validateDataStoreConnection() throws java.io.IOException { // given UiSpecsPropertiesDto properties = new UiSpecsPropertiesDto(); properties.setProperties(getJdbcDataStoreProperties()); // when given().content(properties).contentType(APPLICATION_JSON_UTF8_VALUE) // .accept(APPLICATION_JSON_UTF8_VALUE) // .expect().statusCode(200).log().ifError() // .post(getVersionPrefix() + "/runtimes/check"); }
@Test public void testInitializePropertiesJsonio() throws Exception { Response response = given().accept(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .expect() // .statusCode(200).log().ifError() // .with() // .content(buildTestDataSetSerProps()) // .contentType(ServiceConstants.JSONIO_CONTENT_TYPE) // .post(getVersionPrefix() + "/properties/uispec"); assertNotNull(response); String content = response.asString(); assertEquals(getMockDatasetMainFormUISpecs(), content); }
@Test public void testTriggerOnProperty() throws Exception { String callback = "validate"; String propName = "tagId"; Response response = given().accept(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .expect() // .statusCode(200).log().ifError() // .with() // .content(buildTestDataStoreFormData()) // .contentType(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .post(getVersionPrefix() + "/properties/trigger/{callback}/{propName}", callback, propName); assertNotNull(response); String content = response.asString(); assertNotNull(content); }
@Test public void testInitializePropertiesUiSpecs() throws Exception { Response response = given().accept(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .expect() // .statusCode(200).log().ifError() // .with() // .content(buildTestDataSetFormData()) // .contentType(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .post(getVersionPrefix() + "/properties/uispec"); assertNotNull(response); String content = response.asString(); assertEquals(getMockDatasetMainFormUISpecs(), content); }