use of spock.mock.DetachedMockFactory in project micronaut-core by micronaut-projects.
the class HttpRequestTest method testForEach2.
public void testForEach2() {
final DefaultFullHttpRequest nettyRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, io.netty.handler.codec.http.HttpMethod.GET, "/test");
nettyRequest.headers().add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
nettyRequest.headers().add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML);
HttpRequest<?> request = new NettyHttpRequest(nettyRequest, new DetachedMockFactory().Mock(ChannelHandlerContext.class), ConversionService.SHARED, new HttpServerConfiguration());
final HttpHeaders headers = request.getHeaders();
headers.forEach((name, values) -> {
assertEquals(HttpHeaders.CONTENT_TYPE, name);
assertEquals(2, values.size());
assertTrue(values.contains(MediaType.APPLICATION_JSON));
assertTrue(values.contains(MediaType.APPLICATION_XML));
});
AtomicInteger integer = new AtomicInteger(0);
headers.forEachValue((s, s2) -> integer.incrementAndGet());
assertEquals(2, integer.get());
}
use of spock.mock.DetachedMockFactory in project conductor by Netflix.
the class MockQueueDAOModule method configureQueueDAO.
@Override
public void configureQueueDAO() {
DetachedMockFactory detachedMockFactory = new DetachedMockFactory();
JedisCommands jedisMock = new JedisMock();
ShardSupplier shardSupplier = new ShardSupplier() {
@Override
public Set<String> getQueueShards() {
return new HashSet<>(Collections.singletonList("a"));
}
@Override
public String getCurrentShard() {
return "a";
}
@Override
public String getShardForHost(Host host) {
return "a";
}
};
RedisQueues redisQueues = new RedisQueues(jedisMock, jedisMock, "mockedQueues", shardSupplier, 60000, 120000);
DynoQueueDAO dynoQueueDAO = new DynoQueueDAO(redisQueues);
bind(QueueDAO.class).toInstance(detachedMockFactory.Spy(dynoQueueDAO));
install(new WorkflowExecutorModule());
}
use of spock.mock.DetachedMockFactory in project spock by spockframework.
the class SpockMockFactoryBean method getObject.
@Override
@SuppressWarnings("unchecked")
public T getObject() throws Exception {
if (instance == null) {
MockNature nature = MockNature.valueOf(mockNature.toUpperCase(Locale.ROOT));
instance = new DetachedMockFactory().createMock(name, targetClass, nature, Collections.<String, Object>emptyMap());
}
return instance;
}
use of spock.mock.DetachedMockFactory in project micronaut-core by micronaut-projects.
the class HttpRequestTest method testForEach.
public void testForEach() {
final DefaultFullHttpRequest nettyRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, io.netty.handler.codec.http.HttpMethod.GET, "/test");
nettyRequest.headers().add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
HttpRequest<?> request = new NettyHttpRequest(nettyRequest, new DetachedMockFactory().Mock(ChannelHandlerContext.class), ConversionService.SHARED, new HttpServerConfiguration());
final HttpHeaders headers = request.getHeaders();
headers.forEach((name, values) -> {
assertEquals(HttpHeaders.CONTENT_TYPE, name);
assertEquals(1, values.size());
assertEquals(MediaType.APPLICATION_JSON, values.iterator().next());
});
}
Aggregations