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;
}
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();
}
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);
}
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;
}
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());
}
}
Aggregations