Search in sources :

Example 1 with Action

use of org.talend.components.jira.Action 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 2 with Action

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

the class JiraSinkTest method testInitialize.

/**
 * Checks {@link JiraSink#initialize(RuntimeContainer, ComponentProperties)} sets required fields from
 * {@link ComponentProperties}
 */
@Test
public void testInitialize() {
    JiraSink sink = new JiraSink();
    sink.initialize(null, outputProperties);
    Action action = sink.getAction();
    assertEquals(Action.INSERT, action);
    boolean deleteSubtasks = sink.doDeleteSubtasks();
    assertTrue(deleteSubtasks);
}
Also used : Action(org.talend.components.jira.Action) Test(org.junit.Test)

Example 3 with Action

use of org.talend.components.jira.Action 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

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