本文整理汇总了Java中org.commcare.cases.util.CasePurgeFilter.getInternalCaseGraph方法的典型用法代码示例。如果您正苦于以下问题:Java CasePurgeFilter.getInternalCaseGraph方法的具体用法?Java CasePurgeFilter.getInternalCaseGraph怎么用?Java CasePurgeFilter.getInternalCaseGraph使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.commcare.cases.util.CasePurgeFilter
的用法示例。
在下文中一共展示了CasePurgeFilter.getInternalCaseGraph方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testValidateCaseGraphBeforePurge_simple
import org.commcare.cases.util.CasePurgeFilter; //导入方法依赖的package包/类
/**
* Test correct validation of a graph where 1 case indexes a non-existent node
*/
@Test
public void testValidateCaseGraphBeforePurge_simple() throws Exception {
MockUserDataSandbox sandbox = MockDataUtils.getStaticStorage();
ParseUtils.parseIntoSandbox(this.getClass().getClassLoader().
getResourceAsStream("case_purge/validate_case_graph_test_simple.xml"), sandbox);
IStorageUtilityIndexed<Case> storage = sandbox.getCaseStorage();
HashMap<String, Integer> caseIdsToRecordIds = createCaseIdsMap(storage);
CasePurgeFilter filter = new CasePurgeFilter(storage);
Set<String> nodesExpectedToBeLeft = new HashSet<>();
nodesExpectedToBeLeft.add("case_one");
nodesExpectedToBeLeft.add("case_two");
Set<String[]> edgesExpectedToBeLeft = new HashSet<>();
edgesExpectedToBeLeft.add(new String[]{"case_two", "case_one"});
// Check that the edges and nodes still present in the graph are as expected
DAG<String, int[], String> internalCaseGraph = filter.getInternalCaseGraph();
checkProperNodesPresent(nodesExpectedToBeLeft, internalCaseGraph);
checkProperEdgesPresent(edgesExpectedToBeLeft, internalCaseGraph);
// Check that the correct cases were actually purged
Vector<Integer> expectedToRemove = new Vector<>();
expectedToRemove.add(caseIdsToRecordIds.get("case_three"));
Vector<Integer> removed = storage.removeAll(filter);
checkProperCasesRemoved(expectedToRemove, removed);
}
示例2: testValidateCaseGraphBeforePurge_complex
import org.commcare.cases.util.CasePurgeFilter; //导入方法依赖的package包/类
/**
* Test correct validation of a graph where 2 different cases index the same non-existent node,
* and both of those cases have child nodes
*/
@Test
public void testValidateCaseGraphBeforePurge_complex() throws Exception {
MockUserDataSandbox sandbox = MockDataUtils.getStaticStorage();
ParseUtils.parseIntoSandbox(this.getClass().getClassLoader().
getResourceAsStream("case_purge/validate_case_graph_test_complex.xml"), sandbox);
IStorageUtilityIndexed<Case> storage = sandbox.getCaseStorage();
HashMap<String, Integer> caseIdsToRecordIds = createCaseIdsMap(storage);
CasePurgeFilter filter = new CasePurgeFilter(storage);
Set<String> nodesExpectedToBeLeft = new HashSet<>();
nodesExpectedToBeLeft.add("case_one");
nodesExpectedToBeLeft.add("case_two");
Set<String[]> edgesExpectedToBeLeft = new HashSet<>();
edgesExpectedToBeLeft.add(new String[]{"case_two", "case_one"});
// Check that the edges and nodes still present in the graph are as expected
DAG<String, int[], String> internalCaseGraph = filter.getInternalCaseGraph();
checkProperNodesPresent(nodesExpectedToBeLeft, internalCaseGraph);
checkProperEdgesPresent(edgesExpectedToBeLeft, internalCaseGraph);
// Check that the correct cases were actually purged
Vector<Integer> expectedToRemove = new Vector<>();
expectedToRemove.add(caseIdsToRecordIds.get("case_three"));
expectedToRemove.add(caseIdsToRecordIds.get("case_four"));
expectedToRemove.add(caseIdsToRecordIds.get("case_five"));
expectedToRemove.add(caseIdsToRecordIds.get("case_six"));
expectedToRemove.add(caseIdsToRecordIds.get("case_seven"));
Vector<Integer> removed = storage.removeAll(filter);
checkProperCasesRemoved(expectedToRemove, removed);
}
示例3: testValidateCaseGraphBeforePurge_multipleParents
import org.commcare.cases.util.CasePurgeFilter; //导入方法依赖的package包/类
/**
* Test correct validation of a graph where 1 case indexes 2 other cases - 1 valid and 1 that
* does not exist
*/
@Test
public void testValidateCaseGraphBeforePurge_multipleParents() throws Exception {
MockUserDataSandbox sandbox = MockDataUtils.getStaticStorage();
ParseUtils.parseIntoSandbox(this.getClass().getClassLoader().
getResourceAsStream("case_purge/validate_case_graph_test_multiple_parents.xml"),
sandbox);
IStorageUtilityIndexed<Case> storage = sandbox.getCaseStorage();
HashMap<String, Integer> caseIdsToRecordIds = createCaseIdsMap(storage);
CasePurgeFilter filter = new CasePurgeFilter(storage);
Set<String> nodesExpectedToBeLeft = new HashSet<>();
nodesExpectedToBeLeft.add("case_two");
nodesExpectedToBeLeft.add("case_three");
Set<String[]> edgesExpectedToBeLeft = new HashSet<>();
edgesExpectedToBeLeft.add(new String[]{"case_three", "case_two"});
// Check that the edges and nodes still present in the graph are as expected
DAG<String, int[], String> internalCaseGraph = filter.getInternalCaseGraph();
checkProperNodesPresent(nodesExpectedToBeLeft, internalCaseGraph);
checkProperEdgesPresent(edgesExpectedToBeLeft, internalCaseGraph);
// Check that the correct cases were actually purged
Vector<Integer> expectedToRemove = new Vector<>();
expectedToRemove.add(caseIdsToRecordIds.get("case_one"));
expectedToRemove.add(caseIdsToRecordIds.get("case_four"));
Vector<Integer> removed = storage.removeAll(filter);
checkProperCasesRemoved(expectedToRemove, removed);
}
示例4: testValidateCaseGraphBeforePurge_noRemoval
import org.commcare.cases.util.CasePurgeFilter; //导入方法依赖的package包/类
/**
* Test correct validation of a graph where no cases index a non-existent node, so there is no
* change
*/
@Test
public void testValidateCaseGraphBeforePurge_noRemoval() throws Exception {
MockUserDataSandbox sandbox = MockDataUtils.getStaticStorage();
ParseUtils.parseIntoSandbox(this.getClass().getClassLoader().
getResourceAsStream("case_purge/validate_case_graph_test_no_change.xml"), sandbox);
IStorageUtilityIndexed<Case> storage = sandbox.getCaseStorage();
CasePurgeFilter filter = new CasePurgeFilter(storage);
Set<String> nodesExpectedToBeLeft = new HashSet<>();
nodesExpectedToBeLeft.add("case_one");
nodesExpectedToBeLeft.add("case_two");
nodesExpectedToBeLeft.add("case_three");
nodesExpectedToBeLeft.add("case_four");
Set<String[]> edgesExpectedToBeLeft = new HashSet<>();
edgesExpectedToBeLeft.add(new String[]{"case_two", "case_one"});
// Check that the edges and nodes still present in the graph are as expected
DAG<String, int[], String> internalCaseGraph = filter.getInternalCaseGraph();
checkProperNodesPresent(nodesExpectedToBeLeft, internalCaseGraph);
checkProperEdgesPresent(edgesExpectedToBeLeft, internalCaseGraph);
// Check that the correct cases (none in this case) were actually purged
Vector<Integer> expectedToRemove = new Vector<>();
Vector<Integer> removed = storage.removeAll(filter);
checkProperCasesRemoved(expectedToRemove, removed);
}