本文整理汇总了Java中jersey.repackaged.com.google.common.collect.Sets类的典型用法代码示例。如果您正苦于以下问题:Java Sets类的具体用法?Java Sets怎么用?Java Sets使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Sets类属于jersey.repackaged.com.google.common.collect包,在下文中一共展示了Sets类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateFederatedMetastoreDatabases
import jersey.repackaged.com.google.common.collect.Sets; //导入依赖的package包/类
private void validateFederatedMetastoreDatabases(List<String> mappableDatabases, MetaStoreMapping metaStoreMapping) {
try {
Set<String> allPrimaryDatabases = Sets.newHashSet(primaryDatabasesCache.get(PRIMARY_KEY));
for (String database : mappableDatabases) {
if (allPrimaryDatabases.contains(database.toLowerCase())) {
throw new WaggleDanceException("Database clash, found '"
+ database
+ "' to be mapped for the federated metastore '"
+ metaStoreMapping.getMetastoreMappingName()
+ "' already present in the primary database, please remove the database from the list it can't be accessed via Waggle Dance");
}
if (mappingsByDatabaseName.containsKey(database.toLowerCase())) {
throw new WaggleDanceException("Database clash, found '"
+ database
+ "' to be mapped for the federated metastore '"
+ metaStoreMapping.getMetastoreMappingName()
+ "' already present in another federated database, please remove the database from the list it can't be accessed via Waggle Dance");
}
}
} catch (ExecutionException e) {
throw new WaggleDanceException("Can't validate database clashes", e.getCause());
}
}
示例2: testCallWithRelAndGetParams
import jersey.repackaged.com.google.common.collect.Sets; //导入依赖的package包/类
@Test
public void testCallWithRelAndGetParams() throws Exception {
SchemaLink link = new SchemaLink();
link.setMap(Maps.asMap(Sets.newHashSet(OngoingResponseImpl.METHOD_PARAM_KEY), k -> "get"));
String uri = "http://www.mercateo.com/";
link.setHref(uri);
when(jsonHyperSchema.getByRel(any())).thenReturn(Optional.of(link));
when(response.readEntity(String.class)).thenReturn("");
StringIdCollectionBean sb = new StringIdCollectionBean();
sb.setId("1");
sb.setList(Arrays.asList("1", "2"));
uut.withRequestObject(sb).callWithRel("test");
verify(responseBuilder).buildResponse(any(), any(), any());
verify(webTarget).queryParam("id", "1");
verify(webTarget).queryParam("list", "1", "2");
}
示例3: testCallWithRelAndTemplate_to_many_parameter_for_template
import jersey.repackaged.com.google.common.collect.Sets; //导入依赖的package包/类
@Test
public void testCallWithRelAndTemplate_to_many_parameter_for_template() throws Exception {
SchemaLink mockLink = mock(SchemaLink.class);
when(mockLink.getMap())
.thenReturn(Maps.asMap(Sets.newHashSet(OngoingResponseImpl.METHOD_PARAM_KEY), k -> "get"));
UriTemplate uri = new UriTemplate("http://www.mercateo.com/{id}");
when(mockLink.getHref()).thenReturn(uri);
when(jsonHyperSchema.getByRel(any())).thenReturn(Optional.of(mockLink));
when(response.readEntity(String.class)).thenReturn("");
uut = uut.withRequestObject(new StringIdBean2());
try {
uut.callWithRel("test");
Assert.fail("No IllegalStateException thrown");
} catch (IllegalStateException e) {
assertEquals(
"There is more than one field for the template variable id: [java.lang.String com.mercateo.rest.hateoas.client.impl.OngoingResponseImpl0Test$StringIdBean.id, java.lang.String com.mercateo.rest.hateoas.client.impl.OngoingResponseImpl0Test$StringIdBean2.id]",
e.getMessage());
}
}
示例4: testCallWithRelAndTemplate_missing_parameter_for_template_depr
import jersey.repackaged.com.google.common.collect.Sets; //导入依赖的package包/类
@Test
public void testCallWithRelAndTemplate_missing_parameter_for_template_depr() throws Exception {
SchemaLink mockLink = mock(SchemaLink.class);
when(mockLink.getMap())
.thenReturn(Maps.asMap(Sets.newHashSet(OngoingResponseImpl.METHOD_PARAM_KEY), k -> "get"));
UriTemplate uri = new UriTemplate("http://www.mercateo.com/{id}");
when(mockLink.getHref()).thenReturn(uri);
when(jsonHyperSchema.getByRel(any())).thenReturn(Optional.of(mockLink));
when(response.readEntity(String.class)).thenReturn("");
uut = uut.withRequestObject(new Object());
try {
uut.callWithRel("test");
Assert.fail("No IllegalStateException thrown");
} catch (IllegalStateException e) {
assertEquals("No field found for the template variable id", e.getMessage());
}
}
示例5: testCallWithRelAndTemplate_missing_parameter_for_template
import jersey.repackaged.com.google.common.collect.Sets; //导入依赖的package包/类
@Test
public void testCallWithRelAndTemplate_missing_parameter_for_template() throws Exception {
SchemaLink mockLink = mock(SchemaLink.class);
when(mockLink.getMap())
.thenReturn(Maps.asMap(Sets.newHashSet(OngoingResponseImpl.METHOD_PARAM_KEY), k -> "get"));
UriTemplate uri = new UriTemplate("http://www.mercateo.com/{id}");
when(mockLink.getHref()).thenReturn(uri);
when(jsonHyperSchema.getByRel(any())).thenReturn(Optional.of(mockLink));
when(response.readEntity(String.class)).thenReturn("");
uut = uut.withRequestObject(new Object());
try {
uut.callWithRel("test");
Assert.fail("No IllegalStateException thrown");
} catch (IllegalStateException e) {
assertEquals("No field found for the template variable id", e.getMessage());
}
}
示例6: testCallListWithRel_and_withRequestObject_with_validData
import jersey.repackaged.com.google.common.collect.Sets; //导入依赖的package包/类
@Test
@UseDataProvider("validData")
public void testCallListWithRel_and_withRequestObject_with_validData(String method, String url,
Object requestObject, String expected) throws Exception {
// given
SchemaLink mockLink = mock(SchemaLink.class);
when(mockLink.getMap()).thenReturn(Maps.asMap(Sets.newHashSet(
OngoingResponseImpl.METHOD_PARAM_KEY), k -> method));
UriTemplate uri = new UriTemplate(url);
when(mockLink.getHref()).thenReturn(uri);
when(jsonHyperSchema.getByRel(any())).thenReturn(Optional.of(mockLink));
when(response.readEntity(String.class)).thenReturn("");
// when
uut = uut.withRequestObject(requestObject);
uut.callWithRel("test");
// then
verify(responseBuilder).buildResponse(any(), any(), any());
verify(client).target(eq(new URI(expected)));
}
示例7: testCallListWithRel_and_withRequestObject_with_erroneousData
import jersey.repackaged.com.google.common.collect.Sets; //导入依赖的package包/类
@Test
@UseDataProvider("erroneousData")
public void testCallListWithRel_and_withRequestObject_with_erroneousData(String method,
String url, Object requestObject, Class<? extends Exception> expected)
throws Exception {
// given
SchemaLink mockLink = mock(SchemaLink.class);
when(mockLink.getMap()).thenReturn(Maps.asMap(Sets.newHashSet(
OngoingResponseImpl.METHOD_PARAM_KEY), k -> method));
UriTemplate uri = new UriTemplate(url);
when(mockLink.getHref()).thenReturn(uri);
when(jsonHyperSchema.getByRel(any())).thenReturn(Optional.of(mockLink));
when(response.readEntity(String.class)).thenReturn("");
try {
// when
uut = uut.withRequestObject(requestObject);
uut.callWithRel("test");
fail("expected exception " + expected);
} catch (Exception e) {
// then
assertEquals(expected, e.getClass());
}
}
示例8: testMethodGauges
import jersey.repackaged.com.google.common.collect.Sets; //导入依赖的package包/类
@Test
public void testMethodGauges() throws Exception {
Configuration conf = new Configuration();
conf.set(LensConfConstants.QUERY_METRIC_UNIQUE_ID_CONF_KEY, TestQueryMetrics.class.getSimpleName());
conf.set(LensConfConstants.QUERY_METRIC_DRIVER_STACK_NAME, "testCubeRewriteStackName");
rewriteCtx("select" + " SUM(msr2) from testCube where " + TWO_DAYS_RANGE, conf);
MetricRegistry reg = LensMetricsRegistry.getStaticRegistry();
CubeQueryRewriter cubeQueryRewriter = new CubeQueryRewriter(new Configuration(), new HiveConf());
Set<String> expected = Sets.newHashSet();
int index = 0;
for (ContextRewriter contextRewriter : cubeQueryRewriter.getRewriters()) {
expected.add("lens.MethodMetricGauge.testCubeRewriteStackName-"
+ contextRewriter.getClass().getName() + "-ITER-" + index);
index++;
}
Assert.assertEquals(reg.getGauges().keySet(), expected);
}
示例9: assertNotLanguageBaseIndividual
import jersey.repackaged.com.google.common.collect.Sets; //导入依赖的package包/类
private void assertNotLanguageBaseIndividual(Entity result) {
Assert.assertEquals("wd:Q42", result.getIRI());
Assert.assertEquals(Collections.singletonList("Person"), result.getTypes());
Assert.assertEquals("http://foobar.com/", result.getPropertyValue("url"));
Assert.assertEquals(Sets.newHashSet(
"http://fr.wikipedia.org/wiki/Douglas_Adams",
"http://twitter.com/BarackObama",
"http://www.instagram.com/barackobama",
"http://www.facebook.com/barackobama",
"http://www.youtube.com/channel/UCdn86UYrf54lXfVli9CB6Aw",
"http://plus.google.com/+BarackObama"
), Sets.newHashSet((List<String>) result.getPropertyValue("sameAs")));
Assert.assertEquals("1952-03-11Z", ((Map) result.getPropertyValue("birthDate")).get("@value"));
Assert.assertEquals("xsd:date", ((Map) result.getPropertyValue("birthDate")).get("@type"));
}
示例10: assertNotLanguageBaseIndividual
import jersey.repackaged.com.google.common.collect.Sets; //导入依赖的package包/类
private void assertNotLanguageBaseIndividual(Entity result) {
Assert.assertEquals("wd:Q42", result.getIRI());
Assert.assertEquals(Collections.singletonList("Person"), result.getTypes());
Assert.assertEquals("http://foobar.com/", result.getPropertyValue("url"));
Assert.assertEquals(Sets.newHashSet(
"http://fr.wikipedia.org/wiki/Douglas_Adams",
"http://twitter.com/BarackObama",
"http://www.instagram.com/barackobama",
"http://www.facebook.com/barackobama",
"http://www.youtube.com/channel/UCdn86UYrf54lXfVli9CB6Aw",
"http://plus.google.com/+BarackObama"
), Sets.newHashSet((List) result.getPropertyValue("sameAs")));
}
示例11: testCallWithRel
import jersey.repackaged.com.google.common.collect.Sets; //导入依赖的package包/类
@Test
public void testCallWithRel() throws Exception {
SchemaLink link = new SchemaLink();
link.setMap(Maps.asMap(Sets.newHashSet(OngoingResponseImpl.METHOD_PARAM_KEY), k -> "put"));
String uri = "http://www.mercateo.com/";
link.setHref(uri);
when(jsonHyperSchema.getByRel(any())).thenReturn(Optional.of(link));
when(response.readEntity(String.class)).thenReturn("");
uut.callWithRel("test");
verify(responseBuilder).buildResponse(any(), any(), any());
}
示例12: testCallWithRelAndTemplate
import jersey.repackaged.com.google.common.collect.Sets; //导入依赖的package包/类
@Test
public void testCallWithRelAndTemplate() throws Exception {
SchemaLink mockLink = mock(SchemaLink.class);
when(mockLink.getMap())
.thenReturn(Maps.asMap(Sets.newHashSet(OngoingResponseImpl.METHOD_PARAM_KEY), k -> "get"));
UriTemplate uri = new UriTemplate("http://www.mercateo.com/{id}");
when(mockLink.getHref()).thenReturn(uri);
when(jsonHyperSchema.getByRel(any())).thenReturn(Optional.of(mockLink));
when(response.readEntity(String.class)).thenReturn("");
uut = uut.withRequestObject(new StringIdBean("id1"));
uut.callWithRel("test");
verify(responseBuilder).buildResponse(any(), any(), any());
verify(client).target(eq(new URI("http://www.mercateo.com/id1")));
}
示例13: testCallWithRel_badRequest
import jersey.repackaged.com.google.common.collect.Sets; //导入依赖的package包/类
@Test(expected = WebApplicationException.class)
public void testCallWithRel_badRequest() throws Exception {
SchemaLink mockLink = mock(SchemaLink.class);
when(mockLink.getMap())
.thenReturn(Maps.asMap(Sets.newHashSet(OngoingResponseImpl.METHOD_PARAM_KEY), k -> "put"));
UriTemplate uri = new UriTemplate("http://www.mercateo.com/");
when(mockLink.getHref()).thenReturn(uri);
when(jsonHyperSchema.getByRel(any())).thenReturn(Optional.of(mockLink));
when(response.readEntity(String.class)).thenReturn("");
when(response.getStatus()).thenReturn(400);
when(response.getStatusInfo()).thenReturn(Statuses.from(400));
uut.callWithRel("test");
}
示例14: testCallWithRel_Object
import jersey.repackaged.com.google.common.collect.Sets; //导入依赖的package包/类
@Test
public void testCallWithRel_Object() throws Exception {
SchemaLink mockLink = mock(SchemaLink.class);
when(mockLink.getMap())
.thenReturn(Maps.asMap(Sets.newHashSet(OngoingResponseImpl.METHOD_PARAM_KEY), k -> "put"));
UriTemplate uri = new UriTemplate("http://www.mercateo.com/");
when(mockLink.getHref()).thenReturn(uri);
when(jsonHyperSchema.getByRel(any())).thenReturn(Optional.of(mockLink));
when(response.readEntity(String.class)).thenReturn("");
uut = uut.withRequestObject(new Object());
uut.callWithRel("test");
verify(builder).method(any(), any(Entity.class));
verify(responseBuilder).buildResponse(any(), any(), any());
}
示例15: testDoNotPassEntityForGet
import jersey.repackaged.com.google.common.collect.Sets; //导入依赖的package包/类
@Test
public void testDoNotPassEntityForGet() throws Exception {
SchemaLink mockLink = mock(SchemaLink.class);
when(mockLink.getMap())
.thenReturn(Maps.asMap(Sets.newHashSet(OngoingResponseImpl.METHOD_PARAM_KEY), k -> "get"));
UriTemplate uri = new UriTemplate("http://www.mercateo.com/%7Bid%7D");
when(mockLink.getHref()).thenReturn(uri);
when(jsonHyperSchema.getByRel(any())).thenReturn(Optional.of(mockLink));
when(response.readEntity(String.class)).thenReturn("");
uut = uut.withRequestObject(new StringIdBean("bla"));
uut.callWithRel("test");
verify(builder, never()).method(any(), any(Entity.class));
}