resource = this.getClass().getResource("/config/feed/hive-table-feed-out.xml");
Feed outFeed = (Feed) EntityType.FEED.getUnmarshaller().unmarshal(resource);
ConfigurationStore.get().publish(EntityType.FEED, outFeed);
resource = this.getClass().getResource("/config/process/hive-process.xml");
Process process = (Process) EntityType.PROCESS.getUnmarshaller().unmarshal(resource);
ConfigurationStore.get().publish(EntityType.PROCESS, process);
prepare(process);
OozieProcessWorkflowBuilder builder = new OozieProcessWorkflowBuilder(process);
Path bundlePath = new Path("/falcon/staging/workflows", process.getName());
builder.map(cluster, bundlePath);
assertTrue(fs.exists(bundlePath));
BUNDLEAPP bundle = getBundle(bundlePath);
assertEquals(EntityUtil.getWorkflowName(process).toString(), bundle.getName());
assertEquals(1, bundle.getCoordinator().size());
assertEquals(EntityUtil.getWorkflowName(Tag.DEFAULT, process).toString(),
bundle.getCoordinator().get(0).getName());
String coordPath = bundle.getCoordinator().get(0).getAppPath().replace("${nameNode}", "");
COORDINATORAPP coord = getCoordinator(new Path(coordPath));
HashMap<String, String> props = new HashMap<String, String>();
for (Property prop : coord.getAction().getWorkflow().getConfiguration().getProperty()) {
props.put(prop.getName(), prop.getValue());
}
// verify table props
Map<String, String> expected = getExpectedProperties(inFeed, outFeed, process);
for (Map.Entry<String, String> entry : props.entrySet()) {
if (expected.containsKey(entry.getKey())) {
Assert.assertEquals(entry.getValue(), expected.get(entry.getKey()));
}
}
String wfPath = coord.getAction().getWorkflow().getAppPath().replace("${nameNode}", "");
WORKFLOWAPP parentWorkflow = getParentWorkflow(new Path(wfPath));
testParentWorkflow(process, parentWorkflow);
List<Object> decisionOrForkOrJoin = parentWorkflow.getDecisionOrForkOrJoin();
ACTION hiveNode = (ACTION) decisionOrForkOrJoin.get(4);
Assert.assertEquals("user-hive-job", hiveNode.getName());
JAXBElement<org.apache.falcon.oozie.hive.ACTION> actionJaxbElement = OozieUtils.unMarshalHiveAction(hiveNode);
org.apache.falcon.oozie.hive.ACTION hiveAction = actionJaxbElement.getValue();
Assert.assertEquals(hiveAction.getScript(),
"${nameNode}/falcon/staging/workflows/hive-process/user/script.hql");
Assert.assertEquals(hiveAction.getJobXml(), "${wf:appPath()}/conf/hive-site.xml");
Assert.assertNull(hiveAction.getPrepare());
Assert.assertEquals(Collections.EMPTY_LIST, hiveAction.getArchive());
Assert.assertFalse(hiveAction.getParam().isEmpty());
Assert.assertEquals(11, hiveAction.getParam().size());
Assert.assertTrue(Storage.TYPE.TABLE == ProcessHelper.getStorageType(cluster, process));
assertHCatCredentials(parentWorkflow, wfPath);
ConfigurationStore.get().remove(EntityType.PROCESS, process.getName());
}