@Test public void shouldReturnBadRequestOnPUTMissingResource() throws Exception { given(). contentType(getBaseMediaType()). content(createUpdateRepresentation()). then(). statusCode(Response.Status.BAD_REQUEST.getStatusCode()). when(). put(createRootURL() + "/{id}", "MISSING"); }
@Test public void shouldReturnBadRequestOnMisingResourceWhenPOSTSession() throws Exception { given(). contentType(getBaseMediaType()). content(createSessionRepresentation()). then(). statusCode(Response.Status.BAD_REQUEST.getStatusCode()). when(). post(createRootURL() + "/{id}/session", "MISSING"); } }
@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 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 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 validateConnectionUiSpecs() throws Exception { UiSpecsPropertiesDto propertiesDto = buildTestDataStoreFormData(); given().accept(APPLICATION_JSON_UTF8_VALUE) // .with().content(propertiesDto) // .contentType(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .when()// .post(getVersionPrefix() + "/runtimes/check")// .then()// .statusCode(HttpStatus.OK.value()).log().ifError()// .assertThat().body(notNullValue())// .assertThat().body(instanceOf(String.class)); }
@Test public void validateConnectionJsonio() throws Exception { SerPropertiesDto propertiesDto = buildTestDataStoreSerProps(); given().accept(APPLICATION_JSON_UTF8_VALUE) // .with().content(propertiesDto) // .contentType(ServiceConstants.JSONIO_CONTENT_TYPE) // .when()// .post(getVersionPrefix() + "/runtimes/check")// .then()// .statusCode(HttpStatus.OK.value()).log().ifError() // .assertThat().body(notNullValue())// .assertThat().body(instanceOf(String.class)); }
@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 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 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 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 getDatasetSchemaJsonIo() throws Exception { // given SerPropertiesDto formDataContainer = buildTestDataSetSerProps(); given().accept(APPLICATION_JSON_UTF8_VALUE) // .with().content(formDataContainer) // .contentType(ServiceConstants.JSONIO_CONTENT_TYPE) // .when()// .post(getVersionPrefix() + "/runtimes/schema")// .then()// .statusCode(200).log().ifError() // .assertThat().body(equalTo(MockDatasetRuntime.getSchemaJsonRepresentation())); }
@Test public void getDatasetSchemaUiSpec() throws Exception { // given UiSpecsPropertiesDto formDataContainer = buildTestDataSetFormData(); given().accept(APPLICATION_JSON_UTF8_VALUE) // .with().content(formDataContainer) // .contentType(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .when()// .post(getVersionPrefix() + "/runtimes/schema")// .then()// .statusCode(200).log().ifError() // .assertThat().body(equalTo(MockDatasetRuntime.getSchemaJsonRepresentation())); }
@Test public void getDatasetDataUisSpecs() throws Exception { // given UiSpecsPropertiesDto formDataContainer = buildTestDataSetFormData(); given().accept(APPLICATION_JSON_UTF8_VALUE) // .with().content(formDataContainer) // .contentType(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .when()// .post(getVersionPrefix() + "/runtimes/data")// .then()// .statusCode(200).log().ifError() // .assertThat().body(equalTo(MockDatasetRuntime.getRecordJsonRepresentation())); }
@Test public void getDatasetDataJsonio() throws Exception { // given SerPropertiesDto formDataContainer = buildTestDataSetSerProps(); given().accept(APPLICATION_JSON_UTF8_VALUE) // .with().content(formDataContainer) // .contentType(ServiceConstants.JSONIO_CONTENT_TYPE) // .when()// .post(getVersionPrefix() + "/runtimes/data")// .then()// .statusCode(200).log().ifError() // .assertThat().body(equalTo(MockDatasetRuntime.getRecordJsonRepresentation())); } }
@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 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); }
@Test public void testTriggerOnProperty_nonExistentTrigger() throws Exception { String callback = "toto"; String propName = "tagId"; ApiError errorContainer = given().accept(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .expect() // .statusCode(400).log().ifValidationFails() // .with() // .content(buildTestDataStoreFormData()) // .contentType(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .post(getVersionPrefix() + "/properties/trigger/{callback}/{propName}", callback, propName).as(ApiError.class); assertEquals("Talend_ALL_UNEXPECTED_ARGUMENT", errorContainer.getCode()); assertNotNull(errorContainer.getMessageTitle()); assertNotNull(errorContainer.getMessage()); }