use of org.hamcrest.core.IsEqual in project ddf by codice.
the class TestCswQueryResponseTransformer method whenEmptyResultListExpectOnlyThreeXMLNodes.
@Test
public void whenEmptyResultListExpectOnlyThreeXMLNodes() throws CatalogTransformerException, IOException {
// when
when(mockPrintWriterProvider.build((Class<Metacard>) notNull())).thenReturn(mockPrintWriter);
when(mockPrintWriter.makeString()).thenReturn(new String());
when(mockSourceResponse.getResults()).thenReturn(Collections.emptyList());
when(mockSourceResponse.getRequest()).thenReturn(mockQueryRequest);
when(mockQueryRequest.getQuery()).thenReturn(mockQuery);
when(mockArguments.get(CswConstants.RESULT_TYPE_PARAMETER)).thenReturn(ResultType.RESULTS);
when(mockTransformerManager.getTransformerBySchema(anyString())).thenReturn(mockMetacardTransformer);
// given
transformer.init();
transformer.transform(mockSourceResponse, mockArguments);
transformer.destroy();
// then
ArgumentCaptor<String> pwCaptor = ArgumentCaptor.forClass(String.class);
verify(mockPrintWriter, times(3)).startNode(pwCaptor.capture());
List<String> values = pwCaptor.getAllValues();
assertThat("Missing XML node.", values.get(0), new IsEqual(CswQueryResponseTransformer.RECORDS_RESPONSE_QNAME));
assertThat("Missing XML node.", values.get(1), new IsEqual(CswQueryResponseTransformer.SEARCH_STATUS_QNAME));
assertThat("Missing XML node.", values.get(2), new IsEqual(CswQueryResponseTransformer.SEARCH_RESULTS_QNAME));
}
use of org.hamcrest.core.IsEqual in project jbosstools-openshift by jbosstools.
the class AbstractOpenShiftExplorerItem method expand.
public void expand() {
activateOpenShiftExplorerView();
item.expand();
// There can be some processing, wait for it
new WaitWhile(new JobIsRunning(new Matcher[] { new IsEqual<String>("Loading OpenShift resources...") }), TimePeriod.DEFAULT);
}
use of org.hamcrest.core.IsEqual in project ddf by codice.
the class TestCswQueryResponseTransformer method whenQueryByHitsThenTransformZeroMetacards.
@Test
public void whenQueryByHitsThenTransformZeroMetacards() throws CatalogTransformerException, IOException {
// when
when(mockPrintWriterProvider.build((Class<Metacard>) notNull())).thenReturn(mockPrintWriter);
when(mockPrintWriter.makeString()).thenReturn(new String());
when(mockSourceResponse.getResults()).thenReturn(createResults(1, 10));
when(mockSourceResponse.getRequest()).thenReturn(mockQueryRequest);
when(mockQueryRequest.getQuery()).thenReturn(mockQuery);
when(mockArguments.get(CswConstants.RESULT_TYPE_PARAMETER)).thenReturn(ResultType.HITS);
// given
transformer.init();
transformer.transform(mockSourceResponse, mockArguments);
transformer.destroy();
// then
ArgumentCaptor<String> tmCaptor = ArgumentCaptor.forClass(String.class);
verify(mockTransformerManager, never()).getTransformerBySchema(tmCaptor.capture());
ArgumentCaptor<Map> mapCaptor = ArgumentCaptor.forClass(Map.class);
ArgumentCaptor<Metacard> mcCaptor = ArgumentCaptor.forClass(Metacard.class);
verify(mockMetacardTransformer, never()).transform(mcCaptor.capture(), mapCaptor.capture());
ArgumentCaptor<String> keyCaptor = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<String> valCaptor = ArgumentCaptor.forClass(String.class);
verify(mockPrintWriter, atLeastOnce()).addAttribute(keyCaptor.capture(), valCaptor.capture());
List<String> keys = keyCaptor.getAllValues();
List<String> vals = valCaptor.getAllValues();
int numAttrKeyIndex = keys.indexOf(CswQueryResponseTransformer.NUMBER_OF_RECORDS_RETURNED_ATTRIBUTE);
assertThat("Missing XML attribute.", numAttrKeyIndex != -1, is(true));
String numAttrValue = vals.get(numAttrKeyIndex);
assertThat("Missing XML attribute value.", numAttrValue, new IsEqual("0"));
}
Aggregations