当前位置: 首页>>代码示例>>Java>>正文


Java JsonHyperSchema类代码示例

本文整理汇总了Java中com.mercateo.common.rest.schemagen.JsonHyperSchema的典型用法代码示例。如果您正苦于以下问题:Java JsonHyperSchema类的具体用法?Java JsonHyperSchema怎么用?Java JsonHyperSchema使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JsonHyperSchema类属于com.mercateo.common.rest.schemagen包,在下文中一共展示了JsonHyperSchema类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldSerialize

import com.mercateo.common.rest.schemagen.JsonHyperSchema; //导入依赖的package包/类
@Test
public void shouldSerialize() throws Exception {
    final ObjectMapper objectMapper = new ObjectMapper();

    final Payload payload = new Payload();
    payload.value = "foo";
    final ObjectWithSchema<Payload> element = ObjectWithSchema.create(payload, JsonHyperSchema.from(Collections
            .emptyList()));
    final PaginatedResponse<Payload> listResponse = PaginatedResponse.create(Collections.singletonList(element), 100, 10, 5,
            JsonHyperSchema.from(Collections.emptyList()));

    final String jsonString = objectMapper.writeValueAsString(listResponse);

    assertThat(jsonString).isEqualTo(
            "{\"members\":[{\"value\":\"foo\",\"_schema\":{\"links\":[]}}],\"total\":100,\"offset\":10,\"limit\":5,\"_schema\":{\"links\":[]}}");
}
 
开发者ID:Mercateo,项目名称:rest-schemagen,代码行数:17,代码来源:PaginatedResponseTest.java

示例2: shouldSerialize

import com.mercateo.common.rest.schemagen.JsonHyperSchema; //导入依赖的package包/类
@Test
public void shouldSerialize() throws Exception {
    final ObjectMapper objectMapper = new ObjectMapper();

    final Payload payload = new Payload();
    payload.value = "foo";
    final ObjectWithSchema<Payload> element = ObjectWithSchema.create(payload, JsonHyperSchema.from(Collections
        .emptyList()));
    final ListResponse<Payload> listResponse = new ListResponse<>(Collections.singletonList(element),
            JsonHyperSchema.from(Collections.emptyList()));

    final String jsonString = objectMapper.writeValueAsString(listResponse);

    assertThat(jsonString).isEqualTo(
            "{\"members\":[{\"value\":\"foo\",\"_schema\":{\"links\":[]}}],\"_schema\":{\"links\":[]}}");
}
 
开发者ID:Mercateo,项目名称:rest-schemagen,代码行数:17,代码来源:ListResponseTest.java

示例3: testOnNext

import com.mercateo.common.rest.schemagen.JsonHyperSchema; //导入依赖的package包/类
@Test
public void testOnNext() throws Exception {
    uut.onNext(TestFacts.one);
    ArgumentCaptor<OutboundEvent> cap = ArgumentCaptor.forClass(OutboundEvent.class);
    verify(eventOutput).write(cap.capture());
    OutboundEvent ev = cap.getValue();
    @SuppressWarnings("unchecked")
    JsonHyperSchema jsonHyperSchema = ((ObjectWithSchema<Void>) ev.getData()).schema;
    assertTrue(jsonHyperSchema.getByRel(Rel.CANONICAL).isPresent());
    assertThat(ev.getId(), is(TestFacts.one.id().toString()));
}
 
开发者ID:uweschaefer,项目名称:factcast,代码行数:12,代码来源:FactsObserver0Test.java

示例4: testGetForId

import com.mercateo.common.rest.schemagen.JsonHyperSchema; //导入依赖的package包/类
@Test
public void testGetForId() throws Exception {
    when(factStore.fetchById(TestFacts.one.id())).thenReturn(Optional.of(TestFacts.one));
    ObjectWithSchema<FactJson> value = ObjectWithSchema.create(null, JsonHyperSchema.from(Lists
            .newArrayList()));
    when(schemaCreator.forFactWithId(any())).thenReturn(value);
    ObjectWithSchema<FactJson> result = uut.getForId(TestFacts.one.id().toString());
    assertThat(result, is(value));
}
 
开发者ID:uweschaefer,项目名称:factcast,代码行数:10,代码来源:FactsResource0Test.java

示例5: testGetForIdNotFound

import com.mercateo.common.rest.schemagen.JsonHyperSchema; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test(expected = NotFoundException.class)
public void testGetForIdNotFound() throws Exception {
    when(factStore.fetchById(TestFacts.one.id())).thenThrow(IllegalArgumentException.class);
    ObjectWithSchema<FactJson> value = ObjectWithSchema.create(null, JsonHyperSchema.from(Lists
            .newArrayList()));
    when(schemaCreator.forFactWithId(any())).thenReturn(value);
    uut.getForId(TestFacts.one.id().toString());

}
 
开发者ID:uweschaefer,项目名称:factcast,代码行数:11,代码来源:FactsResource0Test.java

示例6: getListing

import com.mercateo.common.rest.schemagen.JsonHyperSchema; //导入依赖的package包/类
@SuppressWarnings("boxing")
@GET
@Produces(MediaType.APPLICATION_JSON)
public PaginatedResponse<SummaryJsonType> getListing(@BeanParam @NotNull @Valid SearchQueryBean searchQueryBean) {
	final ListingResult<SummaryJsonType> summaries = getSummaryListing(searchQueryBean);

	final LinkFactory<ImplementationType> lf = getImplementationLinkFactory();

	final List<ObjectWithSchema<SummaryJsonType>> listForResponse = summaries.getResultList().stream()
			.map(r -> getResponse(r, lf)).collect(Collectors.toList());

	List<Link> links = Lists.newArrayList();
	lf.forCall(REL_INSTANCE, r -> r.get(IdParameterBean.of(null))).ifPresent(links::add);
	int offset = searchQueryBean.getOffset();
	int limit = searchQueryBean.getLimit();
	PaginationLinkBuilder paginationLinkBuilder = PaginationLinkBuilder.of(summaries.getTotalNumberOfHits(),
			searchQueryBean.getOffset(), searchQueryBean.getLimit());
	links.addAll(paginationLinkBuilder.generateLinks((rel, off, lim) -> {
		searchQueryBean.setLimit(lim);
		searchQueryBean.setOffset(off);
		return lf.forCall(rel, r -> r.getListing(searchQueryBean));
	}));
	links.addAll(createAdditionalLinksForListing(searchQueryBean));

	return PaginatedResponse.create(listForResponse, summaries.getTotalNumberOfHits(), offset, limit,
			JsonHyperSchema.from(links));
}
 
开发者ID:Mercateo,项目名称:rest-jersey-utils,代码行数:28,代码来源:AbstractListingResource.java

示例7: getResponse

import com.mercateo.common.rest.schemagen.JsonHyperSchema; //导入依赖的package包/类
protected ObjectWithSchema<FullJsonType> getResponse(FullJsonType json) {
	final LinkFactory<ImplementationType> factoryForImplementation = getImplementationLinkFactory();
	final Optional<Link> selfLink = factoryForImplementation.forCall(Rel.SELF,
			r -> r.get(IdParameterBean.of(json.getId())));

	final ArrayList<Optional<Link>> result = Lists.newArrayList(selfLink);

	final List<Optional<Link>> additionalLinks = createAdditionalLinksForFullType(json, factoryForImplementation);

	result.addAll(additionalLinks);

	final JsonHyperSchema hyperSchema = JsonHyperSchema.fromOptional(result);
	return ObjectWithSchema.create(json, hyperSchema);
}
 
开发者ID:Mercateo,项目名称:rest-jersey-utils,代码行数:15,代码来源:AbstractListingResource.java

示例8: build

import com.mercateo.common.rest.schemagen.JsonHyperSchema; //导入依赖的package包/类
@Override
public ListResponse<ElementOut> build() {
    requireNonNull(list);
    requireNonNull(elementMapper);
    requireNonNull(containerLinks);

    List<ObjectWithSchema<ElementOut>> mappedList = list.stream().map(elementMapper).collect(
            Collectors.toList());

    JsonHyperSchema schema = JsonHyperSchema.from(containerLinks);
    return ListResponse.create(mappedList, schema);
}
 
开发者ID:Mercateo,项目名称:rest-schemagen,代码行数:13,代码来源:ListResponseBuilder.java

示例9: create

import com.mercateo.common.rest.schemagen.JsonHyperSchema; //导入依赖的package包/类
@SafeVarargs
public final <T> ObjectWithSchema<T> create(T object, List<Link>... linkArray) {
    ArrayList<Link> links = new ArrayList<>();
    Arrays.stream(linkArray).forEach(links::addAll);

    JsonHyperSchema hyperSchema = jsonHyperSchemaCreator.from(links);
    return objectWithSchemaCreator.create(object, hyperSchema);
}
 
开发者ID:Mercateo,项目名称:rest-schemagen,代码行数:9,代码来源:HyperSchemaCreator.java

示例10: ObjectWithSchema

import com.mercateo.common.rest.schemagen.JsonHyperSchema; //导入依赖的package包/类
@JsonCreator
protected ObjectWithSchema(@JsonProperty("object") T object, @JsonProperty("_schema") JsonHyperSchema schema,
        @JsonProperty("_messages") List<Message> messages) {
    // this has to be null, if T is Void, so please, do not "fix" this!
    this.object = object;
    this.schema = requireNonNull(schema);
    this.messages = messages != null ? messages : Collections.emptyList();
}
 
开发者ID:Mercateo,项目名称:rest-schemagen,代码行数:9,代码来源:ObjectWithSchema.java

示例11: setUp

import com.mercateo.common.rest.schemagen.JsonHyperSchema; //导入依赖的package包/类
@Before
public void setUp() {
    responseBuilder = new ResponseBuilder();
    responseBuilder.withValue(value);

    responseBuilder.withElementMapper(integer ->
            ObjectWithSchema.create(integer.longValue(), JsonHyperSchema.from(link3)));
}
 
开发者ID:Mercateo,项目名称:rest-schemagen,代码行数:9,代码来源:ResponseBuilderAbstractTest.java

示例12: shouldSerialize

import com.mercateo.common.rest.schemagen.JsonHyperSchema; //导入依赖的package包/类
@Test
public void shouldSerialize() throws Exception {
    final ObjectMapper objectMapper = new ObjectMapper();

    final Payload payload = new Payload();
    payload.value = "bar";
    final ObjectWithSchema<Payload> objectWithSchema = ObjectWithSchema.create(payload, JsonHyperSchema.from(
            Optional.empty()));

    final String jsonString = objectMapper.writeValueAsString(objectWithSchema);

    assertThat(jsonString).isEqualTo("{\"value\":\"bar\",\"_schema\":{\"links\":[]}}");
}
 
开发者ID:Mercateo,项目名称:rest-schemagen,代码行数:14,代码来源:ObjectWithSchemaTest.java

示例13: shouldWrapObjectAndSchema

import com.mercateo.common.rest.schemagen.JsonHyperSchema; //导入依赖的package包/类
@Test
public void shouldWrapObjectAndSchema() throws Exception {
    Object object = new Object();
    JsonHyperSchema schema = mock(JsonHyperSchema.class);

    ObjectWithSchema<Object> objectWithSchema = new ObjectWithSchemaCreator().create(object, schema);

    assertThat(objectWithSchema.object).isEqualTo(object);
    assertThat(objectWithSchema.schema).isEqualTo(schema);
}
 
开发者ID:Mercateo,项目名称:rest-schemagen,代码行数:11,代码来源:ObjectWithSchemaCreatorTest.java

示例14: from

import com.mercateo.common.rest.schemagen.JsonHyperSchema; //导入依赖的package包/类
public JsonHyperSchema from(Collection<Link> links) {
    return JsonHyperSchema.from(links);
}
 
开发者ID:Mercateo,项目名称:rest-schemagen,代码行数:4,代码来源:JsonHyperSchemaCreator.java

示例15: PaginatedResponse

import com.mercateo.common.rest.schemagen.JsonHyperSchema; //导入依赖的package包/类
protected PaginatedResponse(@JsonProperty("members") List<ObjectWithSchema<T>> members,
        @JsonProperty("total") int total, @JsonProperty("offset") int offset, @JsonProperty("limit") int limit,
        @JsonProperty("_schema") JsonHyperSchema schema) {
    super(new PaginatedList<>(total, offset, limit, members), schema, null);
}
 
开发者ID:Mercateo,项目名称:rest-schemagen,代码行数:6,代码来源:PaginatedResponse.java


注:本文中的com.mercateo.common.rest.schemagen.JsonHyperSchema类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。