Search in sources :

Example 1 with JiraWriter

use of org.talend.components.jira.runtime.writer.JiraWriter 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 JiraWriter

use of org.talend.components.jira.runtime.writer.JiraWriter in project components by Talend.

the class JiraWriteOperationTest method testCreateWriterUpdate.

/**
 * Checks {@link JiraWriteOperation#createWriter(RuntimeContainer)} returns {@link JiraUpdateWriter}, when Update action
 * specified
 */
@Test
public void testCreateWriterUpdate() {
    when(sink.getAction()).thenReturn(Action.UPDATE);
    JiraWriteOperation writeOperation = new JiraWriteOperation(sink);
    JiraWriter writer = writeOperation.createWriter(container);
    assertThat(writer, is(instanceOf(JiraUpdateWriter.class)));
}
Also used : JiraWriter(org.talend.components.jira.runtime.writer.JiraWriter) Test(org.junit.Test)

Example 3 with JiraWriter

use of org.talend.components.jira.runtime.writer.JiraWriter in project components by Talend.

the class JiraWriteOperationTest method testCreateWriterInsert.

/**
 * Checks {@link JiraWriteOperation#createWriter(RuntimeContainer)} returns {@link JiraInsertWriter}, when Insert action
 * specified
 */
@Test
public void testCreateWriterInsert() {
    when(sink.getAction()).thenReturn(Action.INSERT);
    JiraWriteOperation writeOperation = new JiraWriteOperation(sink);
    JiraWriter writer = writeOperation.createWriter(container);
    assertThat(writer, is(instanceOf(JiraInsertWriter.class)));
}
Also used : JiraWriter(org.talend.components.jira.runtime.writer.JiraWriter) Test(org.junit.Test)

Example 4 with JiraWriter

use of org.talend.components.jira.runtime.writer.JiraWriter in project components by Talend.

the class JiraWriteOperationTest method testCreateWriterDelete.

/**
 * Checks {@link JiraWriteOperation#createWriter(RuntimeContainer)} returns {@link JiraDeleteWriter}, when Delete action
 * specified
 */
@Test
public void testCreateWriterDelete() {
    when(sink.getAction()).thenReturn(Action.DELETE);
    JiraWriteOperation writeOperation = new JiraWriteOperation(sink);
    JiraWriter writer = writeOperation.createWriter(container);
    assertThat(writer, is(instanceOf(JiraDeleteWriter.class)));
}
Also used : JiraWriter(org.talend.components.jira.runtime.writer.JiraWriter) Test(org.junit.Test)

Aggregations

JiraWriter (org.talend.components.jira.runtime.writer.JiraWriter)4 Test (org.junit.Test)3 JiraSink (org.talend.components.jira.runtime.JiraSink)1 JiraWriteOperation (org.talend.components.jira.runtime.JiraWriteOperation)1 TJiraOutputProperties (org.talend.components.jira.tjiraoutput.TJiraOutputProperties)1