Search in sources :

Example 1 with TJiraOutputProperties

use of org.talend.components.jira.tjiraoutput.TJiraOutputProperties in project components by Talend.

the class JiraTestsHelper method createWriter.

/**
 * Creates {@link JiraWriter}, which will be tested
 *
 * @param hostPort Jira server url. Example: "http://192.168.99.100:8080/"
 * @param user Jira user
 * @param pass Jira user password
 * @param resource Project or Issue
 * @param action Insert/Update/Delete action
 */
public static JiraWriter createWriter(String hostPort, String user, String pass, Resource resource, Action action) {
    TJiraOutputProperties properties = new TJiraOutputProperties("root");
    properties.init();
    properties.connection.hostUrl.setValue(hostPort);
    properties.connection.basicAuthentication.userId.setValue(user);
    properties.connection.basicAuthentication.password.setValue(pass);
    properties.resource.setValue(resource);
    properties.action.setValue(action);
    JiraSink sink = new JiraSink();
    sink.initialize(null, properties);
    JiraWriteOperation writeOperation = (JiraWriteOperation) sink.createWriteOperation();
    writeOperation.initialize(null);
    JiraWriter jiraWriter = writeOperation.createWriter(null);
    return jiraWriter;
}
Also used : TJiraOutputProperties(org.talend.components.jira.tjiraoutput.TJiraOutputProperties) JiraSink(org.talend.components.jira.runtime.JiraSink) JiraWriteOperation(org.talend.components.jira.runtime.JiraWriteOperation) JiraWriter(org.talend.components.jira.runtime.writer.JiraWriter)

Example 2 with TJiraOutputProperties

use of org.talend.components.jira.tjiraoutput.TJiraOutputProperties in project components by Talend.

the class JiraSourceOrSinkTest method setUp.

/**
 * Prepares required instances for tests
 */
@Before
public void setUp() {
    AvroRegistry registry = new AvroRegistry();
    Schema stringSchema = registry.getConverter(String.class).getSchema();
    Schema.Field jsonField = new Schema.Field("json", stringSchema, null, null, Order.ASCENDING);
    schema = Schema.createRecord("jira", null, null, false, Collections.singletonList(jsonField));
    schema.addProp(TALEND_IS_LOCKED, "true");
    outputProperties = new TJiraOutputProperties("root");
    outputProperties.connection.hostUrl.setValue("hostValue");
    outputProperties.connection.basicAuthentication.userId.setValue("userIdValue");
    outputProperties.connection.basicAuthentication.password.setValue("passwordValue");
    outputProperties.resource.setValue(Resource.ISSUE);
    outputProperties.schema.schema.setValue(schema);
    outputProperties.action.setValue(Action.INSERT);
    sourceOrSink = new JiraSourceOrSink();
}
Also used : AvroRegistry(org.talend.daikon.avro.AvroRegistry) Schema(org.apache.avro.Schema) TJiraOutputProperties(org.talend.components.jira.tjiraoutput.TJiraOutputProperties) Before(org.junit.Before)

Example 3 with TJiraOutputProperties

use of org.talend.components.jira.tjiraoutput.TJiraOutputProperties in project components by Talend.

the class JiraSinkTest method setUp.

/**
 * Prepares required instances for tests
 */
@Before
public void setUp() {
    AvroRegistry registry = new AvroRegistry();
    Schema stringSchema = registry.getConverter(String.class).getSchema();
    Schema.Field jsonField = new Schema.Field("json", stringSchema, null, null, Order.ASCENDING);
    schema = Schema.createRecord("jira", null, null, false, Collections.singletonList(jsonField));
    schema.addProp(TALEND_IS_LOCKED, "true");
    outputProperties = new TJiraOutputProperties("root");
    outputProperties.connection.hostUrl.setValue("hostValue");
    outputProperties.connection.basicAuthentication.userId.setValue("userIdValue");
    outputProperties.connection.basicAuthentication.password.setValue("passwordValue");
    outputProperties.resource.setValue(Resource.ISSUE);
    outputProperties.schema.schema.setValue(schema);
    outputProperties.action.setValue(Action.INSERT);
    outputProperties.deleteSubtasks.setValue(true);
}
Also used : AvroRegistry(org.talend.daikon.avro.AvroRegistry) Schema(org.apache.avro.Schema) TJiraOutputProperties(org.talend.components.jira.tjiraoutput.TJiraOutputProperties) Before(org.junit.Before)

Example 4 with TJiraOutputProperties

use of org.talend.components.jira.tjiraoutput.TJiraOutputProperties in project components by Talend.

the class JiraSink method initialize.

/**
 * Initializes this {@link Sink} with user specified properties
 *
 * @param container {@link RuntimeContainer} instance
 * @param properties user specified properties
 */
@Override
public ValidationResult initialize(RuntimeContainer container, ComponentProperties properties) {
    ValidationResult validate = super.initialize(container, properties);
    if (validate.getStatus() == Result.ERROR) {
        return validate;
    }
    TJiraOutputProperties outputProperties = (TJiraOutputProperties) properties;
    action = outputProperties.action.getValue();
    deleteSubtasks = outputProperties.deleteSubtasks.getValue();
    return ValidationResult.OK;
}
Also used : TJiraOutputProperties(org.talend.components.jira.tjiraoutput.TJiraOutputProperties) ValidationResult(org.talend.daikon.properties.ValidationResult)

Example 5 with TJiraOutputProperties

use of org.talend.components.jira.tjiraoutput.TJiraOutputProperties in project components by Talend.

the class JiraSourceOrSinkTest method testValidateConnectionProperties.

private void testValidateConnectionProperties(String message, String hostUrl, String userId, String password, boolean valid) {
    JiraSourceOrSink sourceOrSink = new JiraSourceOrSink() {

        @Override
        protected ValidationResult validateConnection() {
            return ValidationResult.OK;
        }
    };
    TJiraOutputProperties outputProperties = new TJiraOutputProperties("root");
    outputProperties.connection.hostUrl.setValue(hostUrl);
    outputProperties.connection.basicAuthentication.userId.setValue(userId);
    outputProperties.connection.basicAuthentication.password.setValue(password);
    sourceOrSink.initialize(null, outputProperties);
    ValidationResult vr = sourceOrSink.validate(null);
    if (!valid) {
        assertEquals(message, ValidationResult.Result.ERROR, vr.getStatus());
        assertNotNull(message, vr.getMessage());
    } else {
        assertEquals(message, ValidationResult.Result.OK, vr.getStatus());
    }
}
Also used : TJiraOutputProperties(org.talend.components.jira.tjiraoutput.TJiraOutputProperties) ValidationResult(org.talend.daikon.properties.ValidationResult)

Aggregations

TJiraOutputProperties (org.talend.components.jira.tjiraoutput.TJiraOutputProperties)6 Schema (org.apache.avro.Schema)3 Before (org.junit.Before)3 AvroRegistry (org.talend.daikon.avro.AvroRegistry)3 ValidationResult (org.talend.daikon.properties.ValidationResult)2 Matchers.containsString (org.hamcrest.Matchers.containsString)1 JiraSink (org.talend.components.jira.runtime.JiraSink)1 JiraWriteOperation (org.talend.components.jira.runtime.JiraWriteOperation)1 JiraWriter (org.talend.components.jira.runtime.writer.JiraWriter)1