本文整理了Java中org.assertj.core.api.ListAssert.hasOnlyElementsOfType()
方法的一些代码示例,展示了ListAssert.hasOnlyElementsOfType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ListAssert.hasOnlyElementsOfType()
方法的具体详情如下:
包路径:org.assertj.core.api.ListAssert
类名称:ListAssert
方法名:hasOnlyElementsOfType
暂无
代码示例来源:origin: jdbi/jdbi
@Test
public void testMapMapperOrdering() {
h.execute("insert into something (id, name) values (?, ?)", 1, "hello");
h.execute("insert into something (id, name) values (?, ?)", 2, "world");
List<Map<String, Object>> rs = h.createQuery("select id, name from something")
.mapToMap()
.list();
assertThat(rs).hasSize(2);
assertThat(rs).hasOnlyElementsOfType(LinkedHashMap.class);
}
}
代码示例来源:origin: apache/geode
@Test
@Parameters({"EXECUTE_IN_SERIES", "EXECUTE_IN_PARALLEL"})
public void deadlocksGetResolved(Execution execution) {
final AtomicBoolean lock1 = new AtomicBoolean();
final AtomicBoolean lock2 = new AtomicBoolean();
concurrencyRule.add(() -> {
await().until(() -> lock2.equals(Boolean.TRUE));
lock1.set(true);
return null;
});
concurrencyRule.add(() -> {
await().until(() -> lock1.equals(Boolean.TRUE));
lock2.set(true);
return null;
});
concurrencyRule.setTimeout(Duration.ofSeconds(1));
Throwable thrown = catchThrowable(() -> execution.execute(concurrencyRule));
Throwable cause = thrown.getCause();
assertThat(thrown).isInstanceOf(RuntimeException.class);
assertThat(cause).isInstanceOf(MultipleFailureException.class);
assertThat(((MultipleFailureException) cause).getFailures())
.hasSize(2)
.hasOnlyElementsOfType(TimeoutException.class);
}
代码示例来源:origin: apache/geode
@Test
@Parameters({"EXECUTE_IN_SERIES", "EXECUTE_IN_PARALLEL"})
public void timeoutValueIsRespected(Execution execution) {
Callable<Void> c1 = () -> {
Thread.sleep(5000);
return null;
};
concurrencyRule.setTimeout(Duration.ofSeconds(1));
concurrencyRule.add(c1);
concurrencyRule.add(c1);
await("timeout is respected").until(() -> {
Throwable thrown = catchThrowable(() -> execution.execute(concurrencyRule));
assertThat(((MultipleFailureException) thrown.getCause()).getFailures()).hasSize(2)
.hasOnlyElementsOfType(TimeoutException.class);
return true;
});
}
代码示例来源:origin: org.drools/drools-compiler
private <T> void verifyFactsWithQuery(final Class<T> expectedClassOfFacts, final String queryToGetFacts, final T... factsToVerify) {
final QueryResults results = ksession.getQueryResults(queryToGetFacts);
assertThat(results).isNotEmpty();
final QueryResultsRow resultsRow = results.iterator().next();
assertThat(resultsRow.get("$" + queryToGetFacts)).isInstanceOf(List.class);
final List<Object> objects = (List<Object>) resultsRow.get("$" + queryToGetFacts);
assertThat(objects).hasSize(factsToVerify.length);
assertThat(objects).hasOnlyElementsOfType(expectedClassOfFacts);
assertThat(objects).containsAll(Arrays.asList(factsToVerify));
}
代码示例来源:origin: spring-projects/spring-restdocs
@Test
public void customDefaultSnippets() {
Map<String, Object> configuration = new HashMap<>();
this.configurer.snippets().withDefaults(CliDocumentation.curlRequest())
.apply(configuration, createContext());
assertThat(configuration)
.containsKey(RestDocumentationGenerator.ATTRIBUTE_NAME_DEFAULT_SNIPPETS);
assertThat(configuration
.get(RestDocumentationGenerator.ATTRIBUTE_NAME_DEFAULT_SNIPPETS))
.isInstanceOf(List.class);
@SuppressWarnings("unchecked")
List<Snippet> defaultSnippets = (List<Snippet>) configuration
.get(RestDocumentationGenerator.ATTRIBUTE_NAME_DEFAULT_SNIPPETS);
assertThat(defaultSnippets).hasSize(1);
assertThat(defaultSnippets).hasOnlyElementsOfType(CurlRequestSnippet.class);
}
代码示例来源:origin: cdancy/bitbucket-rest
public void testGetRepositoryListWithLimit() throws Exception {
final MockWebServer server = mockWebServer();
server.enqueue(new MockResponse().setBody(payloadFromResource("/repository-page-truncated.json")).setResponseCode(200));
try (final BitbucketApi baseApi = api(server.getUrl("/"))) {
final RepositoryApi api = baseApi.repositoryApi();
final int start = 0;
final int limit = 2;
final RepositoryPage repositoryPage = api.list(projectKey, start, limit);
final Map<String, ?> queryParams = ImmutableMap.of(startKeyword, start, limitKeyword, limit);
assertSent(server, getMethod, restApiPath + BitbucketApiMetadata.API_VERSION + projectsPath + projectKey + reposEndpoint, queryParams);
assertThat(repositoryPage).isNotNull();
assertThat(repositoryPage.errors()).isEmpty();
final int size = repositoryPage.size();
assertThat(size).isEqualTo(limit);
assertThat(repositoryPage.start()).isEqualTo(start);
assertThat(repositoryPage.limit()).isEqualTo(limit);
assertThat(repositoryPage.isLastPage()).isFalse();
assertThat(repositoryPage.nextPageStart()).isEqualTo(size);
assertThat(repositoryPage.values()).hasSize(size);
assertThat(repositoryPage.values()).hasOnlyElementsOfType(Repository.class);
} finally {
server.shutdown();
}
}
代码示例来源:origin: cdancy/bitbucket-rest
public void testGetProjectListWithLimit() throws Exception {
final MockWebServer server = mockWebServer();
server.enqueue(new MockResponse()
.setBody(payloadFromResource("/project-page-truncated.json"))
.setResponseCode(200));
try (final BitbucketApi baseApi = api(server.getUrl("/"))) {
final int start = 0;
final int limit = 2;
final ProjectPage projectPage = baseApi.projectApi().list(null, null, start, limit);
assertThat(projectPage).isNotNull();
assertThat(projectPage.errors()).isEmpty();
final int size = projectPage.size();
assertThat(size).isEqualTo(limit);
assertThat(projectPage.start()).isEqualTo(start);
assertThat(projectPage.limit()).isEqualTo(limit);
assertThat(projectPage.isLastPage()).isFalse();
assertThat(projectPage.nextPageStart()).isEqualTo(size);
assertThat(projectPage.values()).hasSize(size);
assertThat(projectPage.values()).hasOnlyElementsOfType(Project.class);
final Map<String, ?> queryParams = ImmutableMap.of("start", start, "limit", limit);
assertSent(server, localMethod, restBasePath + BitbucketApiMetadata.API_VERSION + localPath, queryParams);
} finally {
server.shutdown();
}
}
代码示例来源:origin: cdancy/bitbucket-rest
public void testGetRepositoryList() throws Exception {
final MockWebServer server = mockWebServer();
server.enqueue(new MockResponse().setBody(payloadFromResource("/repository-page-full.json")).setResponseCode(200));
try (final BitbucketApi baseApi = api(server.getUrl("/"))) {
final RepositoryApi api = baseApi.repositoryApi();
final RepositoryPage repositoryPage = api.list(projectKey, null, null);
assertSent(server, getMethod, restApiPath + BitbucketApiMetadata.API_VERSION + projectsPath + projectKey + reposEndpoint);
assertThat(repositoryPage).isNotNull();
assertThat(repositoryPage.errors()).isEmpty();
final int size = repositoryPage.size();
final int limit = repositoryPage.limit();
assertThat(size).isLessThanOrEqualTo(limit);
assertThat(repositoryPage.start()).isEqualTo(0);
assertThat(repositoryPage.isLastPage()).isTrue();
assertThat(repositoryPage.values()).hasSize(size);
assertThat(repositoryPage.values()).hasOnlyElementsOfType(Repository.class);
} finally {
server.shutdown();
}
}
代码示例来源:origin: cdancy/bitbucket-rest
public void testGetProjectList() throws Exception {
final MockWebServer server = mockWebServer();
server.enqueue(new MockResponse()
.setBody(payloadFromResource("/project-page-full.json"))
.setResponseCode(200));
try (final BitbucketApi baseApi = api(server.getUrl("/"))) {
final ProjectPage projectPage = baseApi.projectApi().list(null, null, null, null);
assertThat(projectPage).isNotNull();
assertThat(projectPage.errors()).isEmpty();
assertThat(projectPage.size()).isLessThanOrEqualTo(projectPage.limit());
assertThat(projectPage.start()).isEqualTo(0);
assertThat(projectPage.isLastPage()).isTrue();
assertThat(projectPage.values()).hasSize(projectPage.size());
assertThat(projectPage.values()).hasOnlyElementsOfType(Project.class);
assertSent(server, localMethod, restBasePath + BitbucketApiMetadata.API_VERSION + localPath);
} finally {
server.shutdown();
}
}
内容来源于网络,如有侵权,请联系作者删除!