use of org.codice.alliance.nsili.common.UCO.Edge in project alliance by codice.
the class DAGConverterTest method testCCIRMIRViewConversion.
/**
* Test the Message View DAG to Metacard
*
* <p>NSIL_PRODUCT NSIL_APPROVAL NSIL_CARD NSIL_STREAM NSIL_FILE NSIL_METADATASECURITY
* NSIL_RELATED_FILE NSIL_SECURITY NSIL_PART NSIL_SECURITY NSIL_COMMON NSIL_COVERAGE
* NSIL_EXPLOITATION_INFO NSIL_IR NSIL_ASSOCIATION NSIL_RELATION NSIL_SOURCE NSIL_CARD
* NSIL_DESTINATION NSIL_CARD
*/
@Test
public void testCCIRMIRViewConversion() {
DAG dag = new DAG();
DirectedAcyclicGraph<Node, Edge> graph = new DirectedAcyclicGraph<>(Edge.class);
Node productNode = createRootNode();
graph.addVertex(productNode);
addCardNode(graph, productNode);
addFileNode(graph, productNode);
addMetadataSecurity(graph, productNode);
addSecurityNode(graph, productNode);
addIRPart(graph, productNode);
graph.addVertex(productNode);
NsiliCommonUtils.setUCOEdgeIds(graph);
NsiliCommonUtils.setUCOEdges(productNode, graph);
dag.edges = NsiliCommonUtils.getEdgeArrayFromGraph(graph);
dag.nodes = NsiliCommonUtils.getNodeArrayFromGraph(graph);
MetacardImpl metacard = dagConverter.convertDAG(dag, false, SOURCE_ID);
if (SHOULD_PRINT_CARD) {
File file = new File("/tmp/output-ccirm-ir.txt");
if (file.exists()) {
file.delete();
}
try (PrintStream outStream = new PrintStream(file)) {
printMetacard(metacard, outStream);
} catch (IOException ioe) {
// Ignore the error
}
}
// Check top-level meta-card attributes
assertThat(metacard.getTitle(), is(FILE_TITLE));
assertThat(metacard.getId(), is(CARD_ID));
assertThat(metacard.getCreatedDate(), notNullValue());
assertThat(metacard.getEffectiveDate(), notNullValue());
assertThat(metacard.getModifiedDate(), is(cal.getTime()));
assertThat(metacard.getDescription(), is(COM_DESCRIPTION_ABSTRACT));
assertThat(metacard.getLocation(), is(WKT_LOCATION));
assertThat(metacard.getAttribute(Core.RESOURCE_URI).getValue().toString(), is(FILE_PRODUCT_URL));
checkCommonAttributes(metacard);
checkExploitationInfoAttributes(metacard);
checkIRAttributes(metacard);
checkSecurityAttributes(metacard);
checkCoverageAttributes(metacard);
}
use of org.codice.alliance.nsili.common.UCO.Edge in project alliance by codice.
the class DAGConverterTest method testCCIRMCXPViewConversion.
/**
* Test the Message View DAG to Metacard
*
* <p>NSIL_PRODUCT NSIL_APPROVAL NSIL_CARD NSIL_STREAM NSIL_FILE NSIL_METADATASECURITY
* NSIL_RELATED_FILE NSIL_SECURITY NSIL_PART NSIL_SECURITY NSIL_COMMON NSIL_COVERAGE
* NSIL_EXPLOITATION_INFO NSIL_CXP NSIL_ASSOCIATION NSIL_RELATION NSIL_SOURCE NSIL_CARD
* NSIL_DESTINATION NSIL_CARD
*/
@Test
public void testCCIRMCXPViewConversion() {
DAG dag = new DAG();
DirectedAcyclicGraph<Node, Edge> graph = new DirectedAcyclicGraph<>(Edge.class);
Node productNode = createRootNode();
graph.addVertex(productNode);
addCardNode(graph, productNode);
addFileNode(graph, productNode);
addMetadataSecurity(graph, productNode);
addSecurityNode(graph, productNode);
addCxpPart(graph, productNode);
graph.addVertex(productNode);
NsiliCommonUtils.setUCOEdgeIds(graph);
NsiliCommonUtils.setUCOEdges(productNode, graph);
dag.edges = NsiliCommonUtils.getEdgeArrayFromGraph(graph);
dag.nodes = NsiliCommonUtils.getNodeArrayFromGraph(graph);
MetacardImpl metacard = dagConverter.convertDAG(dag, false, SOURCE_ID);
if (SHOULD_PRINT_CARD) {
File file = new File("/tmp/output-ccirm-cxp.txt");
if (file.exists()) {
file.delete();
}
try (PrintStream outStream = new PrintStream(file)) {
printMetacard(metacard, outStream);
} catch (IOException ioe) {
// Ignore the error
}
}
// Check top-level meta-card attributes
assertThat(metacard.getTitle(), is(FILE_TITLE));
assertThat(metacard.getId(), is(CARD_ID));
assertThat(metacard.getCreatedDate(), notNullValue());
assertThat(metacard.getEffectiveDate(), notNullValue());
assertThat(metacard.getModifiedDate(), is(cal.getTime()));
assertThat(metacard.getDescription(), is(COM_DESCRIPTION_ABSTRACT));
assertThat(metacard.getLocation(), is(WKT_LOCATION));
assertThat(metacard.getAttribute(Core.RESOURCE_URI).getValue().toString(), is(FILE_PRODUCT_URL));
checkCommonAttributes(metacard);
checkExploitationInfoAttributes(metacard);
checkSecurityAttributes(metacard);
checkCoverageAttributes(metacard);
}
use of org.codice.alliance.nsili.common.UCO.Edge in project alliance by codice.
the class DAGConverterTest method testRootNodeNotProduct.
@Test
public void testRootNodeNotProduct() {
DAG dag = new DAG();
DirectedAcyclicGraph<Node, Edge> graph = new DirectedAcyclicGraph<>(Edge.class);
// Create invalid root node
Node rootNode = new Node(0, NodeType.ROOT_NODE, NsiliConstants.NSIL_APPROVAL, orb.create_any());
graph.addVertex(rootNode);
Node attribNode = new Node(0, NodeType.ATTRIBUTE_NODE, NsiliConstants.NSIL_CARD, null);
graph.addVertex(attribNode);
graph.addEdge(rootNode, attribNode);
NsiliCommonUtils.setUCOEdgeIds(graph);
NsiliCommonUtils.setUCOEdges(rootNode, graph);
dag.edges = NsiliCommonUtils.getEdgeArrayFromGraph(graph);
dag.nodes = NsiliCommonUtils.getNodeArrayFromGraph(graph);
MetacardImpl metacard = dagConverter.convertDAG(dag, false, SOURCE_ID);
assertThat(metacard.getTitle(), nullValue());
}
use of org.codice.alliance.nsili.common.UCO.Edge in project alliance by codice.
the class DAGConverterTest method testAttributeWithNoValue.
@Test
public void testAttributeWithNoValue() {
DAG dag = new DAG();
DirectedAcyclicGraph<Node, Edge> graph = new DirectedAcyclicGraph<>(Edge.class);
// Create invalid root node
Node rootNode = createRootNode();
graph.addVertex(rootNode);
Node entityNode = new Node(0, NodeType.ENTITY_NODE, NsiliConstants.NSIL_CARD, orb.create_any());
graph.addVertex(entityNode);
graph.addEdge(rootNode, entityNode);
Node attrNode = new Node(0, NodeType.ATTRIBUTE_NODE, NsiliConstants.STATUS, null);
graph.addVertex(attrNode);
graph.addEdge(entityNode, attrNode);
NsiliCommonUtils.setUCOEdgeIds(graph);
NsiliCommonUtils.setUCOEdges(rootNode, graph);
dag.edges = NsiliCommonUtils.getEdgeArrayFromGraph(graph);
dag.nodes = NsiliCommonUtils.getNodeArrayFromGraph(graph);
MetacardImpl metacard = dagConverter.convertDAG(dag, false, SOURCE_ID);
assertThat(metacard.getTitle(), nullValue());
}
use of org.codice.alliance.nsili.common.UCO.Edge in project alliance by codice.
the class DAGConverterTest method testTdlViewConversion.
/**
* Test the Message View DAG to Metacard
*
* <p>NSIL_PRODUCT NSIL_APPROVAL NSIL_CARD NSIL_STREAM NSIL_FILE NSIL_METADATASECURITY
* NSIL_RELATED_FILE NSIL_SECURITY NSIL_PART NSIL_SECURITY NSIL_COMMON NSIL_COVERAGE
* NSIL_EXPLOITATION_INFO NSIL_TDL NSIL_ASSOCIATION NSIL_RELATION NSIL_SOURCE NSIL_CARD
* NSIL_DESTINATION NSIL_CARD
*/
@Test
public void testTdlViewConversion() {
DAG dag = new DAG();
DirectedAcyclicGraph<Node, Edge> graph = new DirectedAcyclicGraph<>(Edge.class);
Node productNode = createRootNode();
graph.addVertex(productNode);
addCardNode(graph, productNode);
addFileNode(graph, productNode);
addStreamNode(graph, productNode);
addMetadataSecurity(graph, productNode);
addSecurityNode(graph, productNode);
addTdlPart(graph, productNode);
graph.addVertex(productNode);
NsiliCommonUtils.setUCOEdgeIds(graph);
NsiliCommonUtils.setUCOEdges(productNode, graph);
dag.edges = NsiliCommonUtils.getEdgeArrayFromGraph(graph);
dag.nodes = NsiliCommonUtils.getNodeArrayFromGraph(graph);
MetacardImpl metacard = dagConverter.convertDAG(dag, false, SOURCE_ID);
if (SHOULD_PRINT_CARD) {
File file = new File("/tmp/output-tdl.txt");
if (file.exists()) {
file.delete();
}
try (PrintStream outStream = new PrintStream(file)) {
printMetacard(metacard, outStream);
} catch (IOException ioe) {
// Ignore the error
}
}
// Check top-level meta-card attributes
assertThat(metacard.getTitle(), is(FILE_TITLE));
assertThat(metacard.getId(), is(CARD_ID));
assertThat(metacard.getCreatedDate(), notNullValue());
assertThat(metacard.getEffectiveDate(), notNullValue());
assertThat(metacard.getModifiedDate(), is(cal.getTime()));
assertThat(metacard.getDescription(), is(COM_DESCRIPTION_ABSTRACT));
assertThat(metacard.getLocation(), is(WKT_LOCATION));
assertThat(metacard.getAttribute(Core.RESOURCE_URI).getValue().toString(), is(FILE_PRODUCT_URL));
checkCommonAttributes(metacard);
checkExploitationInfoAttributes(metacard);
checkTdlAttributes(metacard);
checkSecurityAttributes(metacard);
checkCoverageAttributes(metacard);
}
Aggregations