Skip to content
This repository has been archived by the owner on Apr 16, 2022. It is now read-only.

Added Testing #858

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added Unit Test for XmlManipulationUtils
elduwa committed Mar 22, 2020
commit 818ce9256837256638ed00cb6291aeee851fe635
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.opendatakit.briefcase.util;

import static org.junit.Assert.assertTrue;
import static org.opendatakit.briefcase.util.XmlManipulationUtils.*;

import org.junit.Before;

import org.junit.Test;
import org.kxml2.kdom.Element;
import org.kxml2.kdom.Node;

public class XmlManipulationUtilsTest {

private static final String ROOT_URI = "http://www.w3.org/2002/xforms";
private static final String OPEN_ROSA_NAMESPACE = "http://openrosa.org/xforms";
private static final String OPEN_ROSA_METADATA_TAG = "meta";
private static final String OPEN_ROSA_INSTANCE_ID = "instanceID";
private static final String NAMESPACE_ATTRIBUTE = "xmlns";
private Element tree;

@Before
public void setUp(){
tree = new Element().createElement(null, "html");
tree.setAttribute(null, NAMESPACE_ATTRIBUTE, ROOT_URI);
Element head = new Element().createElement(null, "head");
Element title = new Element().createElement(null, "title");
Element model = new Element().createElement(null, "model");
Element instance = new Element().createElement(null, "instance");
Element data = new Element().createElement(null, "data");
Element meta = new Element().createElement(OPEN_ROSA_NAMESPACE, OPEN_ROSA_METADATA_TAG);
Element instanceId = new Element().createElement(OPEN_ROSA_NAMESPACE, OPEN_ROSA_INSTANCE_ID);
tree.addChild(Node.ELEMENT, head);
head.addChild(Node.ELEMENT, title);
head.addChild(Node.ELEMENT, model);
model.addChild(Node.ELEMENT, instance);
instance.addChild(Node.ELEMENT, data);
data.addChild(Node.ELEMENT, meta);
meta.addChild(Node.ELEMENT, instanceId);
}

@Test
public void find_meta_tag_successful() {
FormInstanceMetadata metadata = getFormInstanceMetadata(tree);
assertTrue(metadata != null);
}

}