use of org.cometd.bayeux.server.ServerMessage.Mutable in project ddf by codice.
the class SearchControllerTest method testMetacardTypeValuesCacheDisabled.
@Test
public void testMetacardTypeValuesCacheDisabled() throws Exception {
final String ID = "id";
Set<String> srcIds = new HashSet<String>();
srcIds.add(ID);
BayeuxServer bayeuxServer = mock(BayeuxServer.class);
ServerChannel channel = mock(ServerChannel.class);
ArgumentCaptor<ServerMessage.Mutable> reply = ArgumentCaptor.forClass(ServerMessage.Mutable.class);
when(bayeuxServer.getChannel(any(String.class))).thenReturn(channel);
SearchRequest request = new SearchRequest(srcIds, getQueryRequest("title LIKE 'Meta*'"), ID);
searchController.setBayeuxServer(bayeuxServer);
// Disable Cache
searchController.setCacheDisabled(true);
searchController.executeQuery(request, mockServerSession, null);
verify(channel, timeout(1000).only()).publish(any(ServerSession.class), reply.capture());
List<Mutable> replies = reply.getAllValues();
assertReplies(replies);
}
use of org.cometd.bayeux.server.ServerMessage.Mutable in project ddf by codice.
the class SearchControllerTest method testMetacardTypeValuesCacheEnabled.
@Test
public void testMetacardTypeValuesCacheEnabled() throws Exception {
final String ID = "id";
Set<String> srcIds = new HashSet<>();
srcIds.add(ID);
BayeuxServer bayeuxServer = mock(BayeuxServer.class);
ServerChannel channel = mock(ServerChannel.class);
ArgumentCaptor<ServerMessage.Mutable> reply = ArgumentCaptor.forClass(ServerMessage.Mutable.class);
when(bayeuxServer.getChannel(any(String.class))).thenReturn(channel);
SearchRequest request = new SearchRequest(srcIds, getQueryRequest("title LIKE 'Meta*'"), ID);
searchController.setBayeuxServer(bayeuxServer);
searchController.setCacheDisabled(false);
searchController.executeQuery(request, mockServerSession, null);
verify(channel, timeout(1000).times(2)).publish(any(ServerSession.class), reply.capture());
List<Mutable> replies = reply.getAllValues();
assertReplies(replies);
}
use of org.cometd.bayeux.server.ServerMessage.Mutable in project ddf by codice.
the class SearchControllerTest method assertReplies.
private void assertReplies(List<Mutable> replies) {
for (Mutable reply : replies) {
assertThat(reply, is(not(nullValue())));
assertThat(reply.getDataAsMap().get(Search.METACARD_TYPES), is(not(nullValue())));
assertThat(reply.getDataAsMap().get(Search.METACARD_TYPES), instanceOf(Map.class));
@SuppressWarnings("unchecked") Map<String, Object> types = (Map<String, Object>) reply.getDataAsMap().get(Search.METACARD_TYPES);
assertThat(types.get("ddf.metacard"), is(not(nullValue())));
assertThat(types.get("ddf.metacard"), instanceOf(Map.class));
@SuppressWarnings("unchecked") Map<String, Map<String, Object>> typeInfo = (Map<String, Map<String, Object>>) types.get("ddf.metacard");
assertThat((String) typeInfo.get("effective").get("format"), is("DATE"));
assertThat((String) typeInfo.get("modified").get("format"), is("DATE"));
assertThat((String) typeInfo.get("created").get("format"), is("DATE"));
assertThat((String) typeInfo.get("expiration").get("format"), is("DATE"));
assertThat((String) typeInfo.get("id").get("format"), is("STRING"));
assertThat((String) typeInfo.get("title").get("format"), is("STRING"));
assertThat((String) typeInfo.get("metadata-content-type").get("format"), is("STRING"));
assertThat((String) typeInfo.get("metadata-content-type-version").get("format"), is("STRING"));
assertThat((String) typeInfo.get("metadata-target-namespace").get("format"), is("STRING"));
assertThat((String) typeInfo.get("resource-uri").get("format"), is("STRING"));
assertThat((Boolean) typeInfo.get("resource-uri").get("indexed"), is(true));
// since resource-size is not indexed, it should be filtered out
assertThat((Boolean) typeInfo.get("resource-size").get("indexed"), is(false));
assertThat((String) typeInfo.get("metadata").get("format"), is("XML"));
assertThat((String) typeInfo.get("location").get("format"), is("GEOMETRY"));
}
}
Aggregations