use of org.opennms.features.topology.api.support.HistoryAwareSearchProvider in project opennms by OpenNMS.
the class BundleContextHistoryManagerTest method verifySearchCriteriaPersistence.
/**
* <p>This method tests the correctness of {@link org.opennms.features.topology.api.support.HistoryAwareSearchProvider#buildCriteriaFromQuery(SearchResult, GraphContainer)} method.
* The {@link SearchCriteria} objects, generated by this method, are compared to those created directly, with the use of a corresponding constructor</p>
* <p>
* Additionally, it checks whether the {@link SavedHistory} objects are saved / loaded correctly and whether there is any data loss / distortion
* </p>
*/
@Test
public void verifySearchCriteriaPersistence() {
// Test 1 - checking whether method buildCriteriaFromQuery is working correctly
// Testing for CategoryHopCriteria & CategorySearchProvider
Criteria criterionNew = ((HistoryAwareSearchProvider) this.startingProviders.get(CriteriaTypes.category)).buildCriteriaFromQuery(this.startingSearchResults.get(CriteriaTypes.category), graphContainerMock);
Assert.assertEquals(this.startingCriteria.get(CriteriaTypes.category), criterionNew);
// Testing for IpLikeHopCriteria & IpLikeSearchProvider
criterionNew = ((HistoryAwareSearchProvider) this.startingProviders.get(CriteriaTypes.ipLike)).buildCriteriaFromQuery(this.startingSearchResults.get(CriteriaTypes.ipLike), graphContainerMock);
Assert.assertEquals(this.startingCriteria.get(CriteriaTypes.ipLike), criterionNew);
// Testing for AlarmHopCriteria & AlarmSearchProvider
criterionNew = ((HistoryAwareSearchProvider) this.startingProviders.get(CriteriaTypes.alarm)).buildCriteriaFromQuery(this.startingSearchResults.get(CriteriaTypes.alarm), graphContainerMock);
Assert.assertEquals(this.startingCriteria.get(CriteriaTypes.alarm), criterionNew);
// Step 1 - providing GraphContainer with a starting Criteria set
for (Criteria criteria : this.startingCriteria.values()) {
graphContainerMock.addCriteria(criteria);
}
// Saving and then loading history
String fragment = historyManager.saveOrUpdateHistory("admin", graphContainerMock);
historyManager.applyHistory(fragment, graphContainerMock);
Assert.assertNotNull(capturedCriteria);
Assert.assertThat(startingCriteria.values(), containsInAnyOrder(capturedCriteria.toArray()));
}
Aggregations