Search in sources :

Example 1 with Resource

use of org.talend.components.jira.Resource in project components by Talend.

the class TJiraInputProperties method refreshLayout.

/**
 * {@inheritDoc}
 */
@Override
public void refreshLayout(Form form) {
    super.refreshLayout(form);
    Resource resourceValue = resource.getValue();
    if (form.getName().equals(Form.MAIN)) {
        // refresh after resource changed
        switch(resourceValue) {
            case PROJECT:
                {
                    form.getWidget(jql.getName()).setHidden(true);
                    form.getWidget(projectId.getName()).setHidden(false);
                    break;
                }
            case ISSUE:
                {
                    form.getWidget(jql.getName()).setHidden(false);
                    form.getWidget(projectId.getName()).setHidden(true);
                    break;
                }
        }
    }
    if (form.getName().equals(Form.ADVANCED)) {
        // refresh after resource changed
        switch(resourceValue) {
            case PROJECT:
                {
                    form.getWidget(batchSize.getName()).setHidden(true);
                    break;
                }
            case ISSUE:
                {
                    form.getWidget(batchSize.getName()).setHidden(false);
                    break;
                }
        }
    }
}
Also used : Resource(org.talend.components.jira.Resource)

Example 2 with Resource

use of org.talend.components.jira.Resource in project components by Talend.

the class TJiraOutputProperties method refreshLayout.

/**
 * {@inheritDoc}
 */
@Override
public void refreshLayout(Form form) {
    super.refreshLayout(form);
    Action actionValue = action.getValue();
    Resource resourceValue = resource.getValue();
    if (form.getName().equals(Form.MAIN)) {
        // sets corresponding schema property for chosen action
        switch(actionValue) {
            case DELETE:
                {
                    schema.schema.setValue(deleteSchema);
                    break;
                }
            case INSERT:
                {
                    schema.schema.setValue(insertSchema);
                    break;
                }
            case UPDATE:
                {
                    schema.schema.setValue(updateSchema);
                    break;
                }
        }
    }
    if (form.getName().equals(Form.ADVANCED)) {
        // deleteSubtasks property visibility
        if (DELETE.equals(actionValue) && ISSUE.equals(resourceValue)) {
            form.getWidget(deleteSubtasks.getName()).setHidden(false);
        } else {
            form.getWidget(deleteSubtasks.getName()).setHidden(true);
        }
    }
}
Also used : Action(org.talend.components.jira.Action) Resource(org.talend.components.jira.Resource)

Example 3 with Resource

use of org.talend.components.jira.Resource in project components by Talend.

the class TJiraInputPropertiesTest method testSetupProperties.

/**
 * Checks {@link TJiraInputProperties#setupProperties()} sets correct initial property values
 */
@Test
public void testSetupProperties() {
    TJiraInputProperties properties = new TJiraInputProperties("root");
    properties.setupProperties();
    Resource resourceValue = properties.resource.getValue();
    String jqlValue = properties.jql.getValue();
    String projectIdValue = properties.projectId.getValue();
    int batchSizeValue = properties.batchSize.getValue();
    assertThat(resourceValue, equalTo(Resource.ISSUE));
    assertThat(jqlValue, equalTo("summary ~ \\\"some word\\\" AND project=PROJECT_ID"));
    assertThat(projectIdValue, equalTo(""));
    assertThat(batchSizeValue, equalTo(50));
}
Also used : Resource(org.talend.components.jira.Resource) Test(org.junit.Test)

Example 4 with Resource

use of org.talend.components.jira.Resource in project components by Talend.

the class TJiraOutputPropertiesTest method testSetupProperties.

/**
 * Checks {@link TJiraOutputProperties#setupProperties()} sets correct initial property values
 */
@Test
public void testSetupProperties() {
    AvroRegistry registry = new AvroRegistry();
    Schema stringSchema = registry.getConverter(String.class).getSchema();
    Schema.Field jsonField = new Schema.Field("json", stringSchema, null, null, Order.ASCENDING);
    Schema expectedSchema = Schema.createRecord("jira", null, null, false, Collections.singletonList(jsonField));
    expectedSchema.addProp(TALEND_IS_LOCKED, "true");
    TJiraOutputProperties properties = new TJiraOutputProperties("root");
    properties.setupProperties();
    Action actionValue = properties.action.getValue();
    Resource resourceValue = properties.resource.getValue();
    boolean deleteSubtasksValue = properties.deleteSubtasks.getValue();
    Mode modeValue = properties.mode.getValue();
    Schema schema = properties.schema.schema.getValue();
    assertThat(actionValue, equalTo(Action.INSERT));
    assertThat(resourceValue, equalTo(Resource.ISSUE));
    assertThat(deleteSubtasksValue, equalTo(true));
    assertThat(modeValue, equalTo(Mode.ADVANCED));
    assertThat(schema, equalTo(expectedSchema));
}
Also used : Action(org.talend.components.jira.Action) AvroRegistry(org.talend.daikon.avro.AvroRegistry) Schema(org.apache.avro.Schema) Mode(org.talend.components.jira.Mode) Resource(org.talend.components.jira.Resource) Test(org.junit.Test)

Aggregations

Resource (org.talend.components.jira.Resource)4 Test (org.junit.Test)2 Action (org.talend.components.jira.Action)2 Schema (org.apache.avro.Schema)1 Mode (org.talend.components.jira.Mode)1 AvroRegistry (org.talend.daikon.avro.AvroRegistry)1