Search in sources :

Example 1 with DomainType

use of com.thinkbiganalytics.feedmgr.rest.model.DomainType in project kylo by Teradata.

the class IntegrationTestBase method getDomainTypes.

protected DomainType[] getDomainTypes() {
    LOG.info("Getting domain types");
    Response response = given(DomainTypesController.BASE).get();
    response.then().statusCode(HTTP_OK);
    return response.as(DomainType[].class);
}
Also used : Response(com.jayway.restassured.response.Response) DomainType(com.thinkbiganalytics.feedmgr.rest.model.DomainType)

Example 2 with DomainType

use of com.thinkbiganalytics.feedmgr.rest.model.DomainType in project kylo by Teradata.

the class DomainTypeIT method testCreateAndUpdateDatasource.

@Test
public void testCreateAndUpdateDatasource() {
    FieldStandardizationRule toUpperCase = new FieldStandardizationRule();
    FieldValidationRule email = new FieldValidationRule();
    toUpperCase.setName("Uppercase");
    toUpperCase.setDisplayName("Uppercase");
    toUpperCase.setDescription("Convert string to uppercase");
    toUpperCase.setObjectClassType("com.thinkbiganalytics.policy.standardization.UppercaseStandardizer");
    toUpperCase.setObjectShortClassType("UppercaseStandardizer");
    email.setName("email");
    email.setDisplayName("Email");
    email.setDescription("Valid email address");
    email.setObjectClassType("com.thinkbiganalytics.policy.validation.EmailValidator");
    email.setObjectShortClassType("EmailValidator");
    DomainType[] initialDomainTypes = getDomainTypes();
    // create new domain type
    DomainType dt = new DomainType();
    dt.setTitle("Domain Type 1");
    dt.setDescription("domain type created by integration tests");
    DomainType response = createDomainType(dt);
    assertEquals(dt.getTitle(), response.getTitle());
    assertEquals(dt.getDescription(), response.getDescription());
    assertEquals(null, response.getIcon());
    assertEquals(null, response.getIconColor());
    // assert new domain type was added
    DomainType[] currentDomainTypes = getDomainTypes();
    assertEquals(initialDomainTypes.length + 1, currentDomainTypes.length);
    // update existing domain type
    dt = getDomainType(response.getId());
    dt.setTitle("Domain Type 1 with updated title");
    dt.setDescription("domain type description updated by integration tests");
    dt.setIcon("stars");
    dt.setIconColor("green");
    DefaultField field = new DefaultField();
    Tag tag1 = new DefaultTag("tag1");
    Tag tag2 = new DefaultTag("tag2");
    field.setTags(Arrays.asList(tag1, tag2));
    field.setName("field-name");
    field.setDerivedDataType("decimal");
    field.setPrecisionScale("9, 3");
    dt.setField(field);
    dt.setFieldNamePattern("field-name-pattern");
    dt.setFieldPolicy(newPolicyBuilder(null).withStandardisation(toUpperCase).withValidation(email).toPolicy());
    dt.setRegexPattern("regex-pattern");
    DomainType updated = createDomainType(dt);
    assertEquals(dt.getTitle(), updated.getTitle());
    assertEquals(dt.getDescription(), updated.getDescription());
    assertEquals("stars", updated.getIcon());
    assertEquals("green", updated.getIconColor());
    Field updatedField = updated.getField();
    assertEquals(field.getName(), updatedField.getName());
    assertEquals(field.getDerivedDataType(), updatedField.getDerivedDataType());
    assertEquals(field.getPrecisionScale(), updatedField.getPrecisionScale());
    assertEquals(field.getTags().size(), updatedField.getTags().size());
    assertEquals(tag1.getName(), updatedField.getTags().get(0).getName());
    assertEquals(tag2.getName(), updatedField.getTags().get(1).getName());
    assertEquals(dt.getFieldNamePattern(), updated.getFieldNamePattern());
    assertEquals(dt.getRegexPattern(), updated.getRegexPattern());
    FieldStandardizationRule updatedStandardisation = updated.getFieldPolicy().getStandardization().get(0);
    assertEquals(toUpperCase.getName(), updatedStandardisation.getName());
    assertEquals(toUpperCase.getObjectShortClassType(), updatedStandardisation.getObjectShortClassType());
    FieldValidationRule updatedValidation = updated.getFieldPolicy().getValidation().get(0);
    assertEquals(email.getName(), updatedValidation.getName());
    assertEquals(email.getObjectShortClassType(), updatedValidation.getObjectShortClassType());
    // assert domain type was updated, rather than added
    currentDomainTypes = getDomainTypes();
    assertEquals(initialDomainTypes.length + 1, currentDomainTypes.length);
    // delete domain type
    deleteDomainType(dt.getId());
    currentDomainTypes = getDomainTypes();
    assertEquals(initialDomainTypes.length, currentDomainTypes.length);
    // assert domain type was removed
    getDomainTypeExpectingStatus(dt.getId(), HTTP_NOT_FOUND);
}
Also used : DefaultField(com.thinkbiganalytics.discovery.model.DefaultField) Field(com.thinkbiganalytics.discovery.schema.Field) DomainType(com.thinkbiganalytics.feedmgr.rest.model.DomainType) FieldValidationRule(com.thinkbiganalytics.policy.rest.model.FieldValidationRule) DefaultField(com.thinkbiganalytics.discovery.model.DefaultField) DefaultTag(com.thinkbiganalytics.discovery.model.DefaultTag) Tag(com.thinkbiganalytics.discovery.schema.Tag) DefaultTag(com.thinkbiganalytics.discovery.model.DefaultTag) FieldStandardizationRule(com.thinkbiganalytics.policy.rest.model.FieldStandardizationRule) Test(org.junit.Test)

Example 3 with DomainType

use of com.thinkbiganalytics.feedmgr.rest.model.DomainType in project kylo by Teradata.

the class IntegrationTestBase method deleteExistingDomainTypes.

protected void deleteExistingDomainTypes() {
    LOG.info("Deleting existing Domain Types");
    DomainType[] domainTypes = getDomainTypes();
    for (DomainType domainType : domainTypes) {
        deleteDomainType(domainType.getId());
    }
    domainTypes = getDomainTypes();
    Assert.assertTrue(domainTypes.length == 0);
}
Also used : DomainType(com.thinkbiganalytics.feedmgr.rest.model.DomainType)

Aggregations

DomainType (com.thinkbiganalytics.feedmgr.rest.model.DomainType)3 Response (com.jayway.restassured.response.Response)1 DefaultField (com.thinkbiganalytics.discovery.model.DefaultField)1 DefaultTag (com.thinkbiganalytics.discovery.model.DefaultTag)1 Field (com.thinkbiganalytics.discovery.schema.Field)1 Tag (com.thinkbiganalytics.discovery.schema.Tag)1 FieldStandardizationRule (com.thinkbiganalytics.policy.rest.model.FieldStandardizationRule)1 FieldValidationRule (com.thinkbiganalytics.policy.rest.model.FieldValidationRule)1 Test (org.junit.Test)1