@Test public void testSizeIsTheNumberOfOffers() { int currentSize = 0; while (currentSize < SIZE && queue.offer(currentSize)) { currentSize++; assertThat(queue, hasSize(currentSize)); } }
@Test public void resourceChainWithoutCaching() throws Exception { this.registration.resourceChain(false); ResourceHttpRequestHandler handler = getHandler("/resources/**"); List<ResourceResolver> resolvers = handler.getResourceResolvers(); assertThat(resolvers, Matchers.hasSize(2)); assertThat(resolvers.get(0), Matchers.instanceOf(WebJarsResourceResolver.class)); assertThat(resolvers.get(1), Matchers.instanceOf(PathResourceResolver.class)); List<ResourceTransformer> transformers = handler.getResourceTransformers(); assertThat(transformers, Matchers.hasSize(0)); }
@Test(dataProvider = "empty") public void offer_whenEmpty(Queue<Integer> queue) { assertThat(queue.offer(1), is(true)); assertThat(queue, hasSize(1)); }
private <T extends KsqlEntity> T makeSingleRequest( final KsqlRequest ksqlRequest, final Class<T> expectedEntityType) { final List<T> entities = makeMultipleRequest(ksqlRequest, expectedEntityType); assertThat(entities, hasSize(1)); return entities.get(0); }
@Test public void shouldFilterNullCommands() { // Given: final ConsumerRecords<CommandId, Command> records = buildRecords( commandId, null, commandId, command); when(commandTopic.getNewCommands(any())).thenReturn(records); // When: final List<QueuedCommand> commands = commandStore.getNewCommands(); // Then: assertThat(commands, hasSize(1)); assertThat(commands.get(0).getCommandId(), equalTo(commandId)); assertThat(commands.get(0).getCommand(), equalTo(command)); }
@Test public void trackPopulationJobs() { assertThat( jobController.getPopulationJobs(), is( empty() ) ); IndexPopulationJob populationJob = mock( IndexPopulationJob.class ); jobController.startIndexPopulation( populationJob ); assertThat( jobController.getPopulationJobs(), hasSize( 1 ) ); IndexPopulationJob populationJob2 = mock( IndexPopulationJob.class ); jobController.startIndexPopulation( populationJob2 ); assertThat( jobController.getPopulationJobs(), hasSize( 2 ) ); }
private void testSingleComponent(Class<?> target, Class<?>... stereotypes) { CandidateComponentsMetadata metadata = compile(target); assertThat(metadata, hasComponent(target, stereotypes)); assertThat(metadata.getItems(), hasSize(1)); }
@Test public void resourceChainWithoutCaching() throws Exception { this.registration.resourceChain(false); ResourceWebHandler handler = getHandler("/resources/**"); List<ResourceResolver> resolvers = handler.getResourceResolvers(); assertThat(resolvers, Matchers.hasSize(2)); assertThat(resolvers.get(0), Matchers.instanceOf(WebJarsResourceResolver.class)); assertThat(resolvers.get(1), Matchers.instanceOf(PathResourceResolver.class)); List<ResourceTransformer> transformers = handler.getResourceTransformers(); assertThat(transformers, Matchers.hasSize(0)); }
private MockProducer setupSubscriberAndValidate(WriteStreamSubscriber sub, int expectedSubCount) { MockProducer mockProducer = setupSubscriber(sub); assertThat("Subscriber not added.", interceptor.getSubscribers(), hasSize(expectedSubCount)); assertThat("Subscriber not added.", interceptor.getSubscribers().get(expectedSubCount - 1), equalTo(sub)); return mockProducer; }
@Test public void getAttachments() throws Exception { Uri uri = Uri.parse("content://not-a-valid-content-uri"); List<Uri> result = new DefaultAttachmentProvider().getAttachments(RuntimeEnvironment.application, new CoreConfigurationBuilder(new Application()).setAttachmentUris(uri.toString()).build()); assertThat(result, hasSize(1)); assertEquals(uri, result.get(0)); }
@Test public void parseWebSocketExtensions() { List<String> extensions = new ArrayList<>(); extensions.add("x-foo-extension, x-bar-extension"); extensions.add("x-test-extension"); this.headers.put(WebSocketHttpHeaders.SEC_WEBSOCKET_EXTENSIONS, extensions); List<WebSocketExtension> parsedExtensions = this.headers.getSecWebSocketExtensions(); assertThat(parsedExtensions, Matchers.hasSize(3)); }
@Test public void untrackFinishedPopulations() { IndexPopulationJob populationJob = getIndexPopulationJob(); jobController.startIndexPopulation( populationJob ); assertThat( jobController.getPopulationJobs(), hasSize( 1 ) ); executer.runJob(); assertThat( jobController.getPopulationJobs(), hasSize( 0 ) ); verify( populationJob ).run(); }
@Test(dataProvider = "populated") public void remove_whenPopulated(Queue<Integer> queue) { Integer first = queue.peek(); assertThat(queue.remove(), is(first)); assertThat(queue, hasSize(POPULATED_SIZE - 1)); assertThat(queue.contains(first), is(false)); }
private void testComponent(Class<?>... classes) { CandidateComponentsMetadata metadata = compile(classes); for (Class<?> c : classes) { assertThat(metadata, hasComponent(c, Component.class)); } assertThat(metadata.getItems(), hasSize(classes.length)); }
@Test public void testHierarchyPackages() { String pkgName = "a.b.c.d.e"; List<JavaPackage> packages = Collections.singletonList(newPkg(pkgName)); List<JPackage> out = sources.getHierarchyPackages(packages); assertThat(out, hasSize(1)); JPackage jPkg = out.get(0); assertThat(jPkg.getName(), is(pkgName)); assertThat(jPkg.getClasses(), hasSize(1)); }
@Test void addOnlyLastComponent() { LifeSupport lifeSupport = newLifeSupport(); Lifecycle lastComponent = mock( Lifecycle.class ); lifeSupport.setLast( lastComponent ); lifeSupport.start(); List<Lifecycle> lifecycleInstances = lifeSupport.getLifecycleInstances(); assertSame( lastComponent, lifecycleInstances.get( 0 ) ); assertThat( lifecycleInstances, hasSize( 1 ) ); }
@Test public void shouldFindConstraintsBySchema() throws Exception { // GIVEN addConstraints( "FOO", "prop" ); try ( Transaction tx = beginTransaction() ) { int label = tx.tokenWrite().labelGetOrCreateForName( "FOO" ); int prop = tx.tokenWrite().propertyKeyGetOrCreateForName( "prop" ); LabelSchemaDescriptor descriptor = labelSchemaDescriptor( label, prop ); //WHEN List<ConstraintDescriptor> constraints = asList( tx.schemaRead().constraintsGetForSchema( descriptor ) ); // THEN assertThat( constraints, hasSize( 1 ) ); assertThat( constraints.get( 0 ).schema().getPropertyId(), equalTo( prop ) ); } }
@Test public void registeredMappings() { Map<String, HandlerMethod> handlerMethods = this.messageHandler.getHandlerMethods(); assertNotNull(handlerMethods); assertThat(handlerMethods.keySet(), Matchers.hasSize(3)); }
@Test public void shouldFindAllConstraints() throws Exception { // GIVEN addConstraints( "FOO", "prop1", "BAR", "prop2", "BAZ", "prop3" ); try ( Transaction tx = beginTransaction() ) { //WHEN List<ConstraintDescriptor> constraints = asList( tx.schemaRead().constraintsGetAll() ); // THEN assertThat( constraints, hasSize( 3 ) ); } }
@Test(dataProvider = "populated") public void poll_whenPopulated(Queue<Integer> queue) { Integer first = queue.peek(); assertThat(queue.poll(), is(first)); assertThat(queue, hasSize(POPULATED_SIZE - 1)); assertThat(queue.contains(first), is(false)); }