本文整理汇总了Java中com.theoryinpractise.halbuilder.api.Representation.getLinkByRel方法的典型用法代码示例。如果您正苦于以下问题:Java Representation.getLinkByRel方法的具体用法?Java Representation.getLinkByRel怎么用?Java Representation.getLinkByRel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.theoryinpractise.halbuilder.api.Representation
的用法示例。
在下文中一共展示了Representation.getLinkByRel方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSlotRepresentationWithNextAndPrevLinks
import com.theoryinpractise.halbuilder.api.Representation; //导入方法依赖的package包/类
@Test
public void testSlotRepresentationWithNextAndPrevLinks()
throws JsonProcessingException {
Slot thisSlot = newSlotStub(2);
Slot prevSlot = newSlotStub(1);
Slot nextSlot = newSlotStub(3);
Representation rep = factory.newSlotRepresentation(thisSlot,
Optional.of(prevSlot), Optional.of(nextSlot));
System.out.println(rep
.toString(HAL_JSON, PRETTY_PRINT, COALESCE_ARRAYS));
Link link = rep.getLinkByRel("prev");
assertEquals(slotUriBuilder.build(prevSlot.getId()).toString(),
link.getHref());
link = rep.getLinkByRel("next");
assertEquals(slotUriBuilder.build(nextSlot.getId()).toString(),
link.getHref());
String doctorId = rep.getValue("doctorId", "").toString();
assertEquals(thisSlot.getDoctorId(), doctorId);
}
示例2: testSlotRepresentationWithPrevLink
import com.theoryinpractise.halbuilder.api.Representation; //导入方法依赖的package包/类
@Test
public void testSlotRepresentationWithPrevLink()
throws JsonProcessingException {
Slot thisSlot = newSlotStub(2);
Slot prevSlot = newSlotStub(1);
Representation rep = factory.newSlotRepresentation(thisSlot,
Optional.of(prevSlot), Optional.<Slot> empty());
System.out.println(rep
.toString(HAL_JSON, PRETTY_PRINT, COALESCE_ARRAYS));
Link link = rep.getLinkByRel("prev");
assertEquals(slotUriBuilder.build(prevSlot.getId()).toString(),
link.getHref());
link = rep.getLinkByRel("next");
assertNull(link);
String doctorId = rep.getValue("doctorId", "").toString();
assertEquals(thisSlot.getDoctorId(), doctorId);
}
示例3: testSlotRepresentationWithNextLink
import com.theoryinpractise.halbuilder.api.Representation; //导入方法依赖的package包/类
@Test
public void testSlotRepresentationWithNextLink()
throws JsonProcessingException {
Slot thisSlot = newSlotStub(1);
Slot nextSlot = newSlotStub(2);
Representation rep = factory.newSlotRepresentation(thisSlot,
Optional.<Slot> empty(), Optional.of(nextSlot));
System.out.println(rep
.toString(HAL_JSON, PRETTY_PRINT, COALESCE_ARRAYS));
Link link = rep.getLinkByRel("next");
assertEquals(slotUriBuilder.build(nextSlot.getId()).toString(),
link.getHref());
link = rep.getLinkByRel("prev");
assertNull(link);
String doctorId = rep.getValue("doctorId", "").toString();
assertEquals(thisSlot.getDoctorId(), doctorId);
}
示例4: testSlotsRepresentation
import com.theoryinpractise.halbuilder.api.Representation; //导入方法依赖的package包/类
@Test
public void testSlotsRepresentation() {
List<Slot> slots = newSlotsStub();
Representation rep = factory.newSlotsRepresentation(slots);
System.out.println(rep
.toString(HAL_JSON, PRETTY_PRINT, COALESCE_ARRAYS));
Link link = rep.getLinkByRel("self");
assertEquals(slotsUriBuilder.build().toString(), link.getHref());
link = rep.getLinkByRel("item");
String href = link.getHref();
assertTrue(slots.stream().anyMatch(
slot -> href.endsWith(String.valueOf(slot.getId()))));
link = rep.getLinkByRel("start");
assertEquals(slotUriBuilder.build(slots.get(0).getId()).toString(),
link.getHref());
}
示例5: testApptRepresentationWithSelfLink
import com.theoryinpractise.halbuilder.api.Representation; //导入方法依赖的package包/类
@Test
public void testApptRepresentationWithSelfLink() {
Appointment appt = newApptStub(1);
Representation rep = factory.newAppointmentRepresentation(appt);
System.out.println(rep
.toString(HAL_JSON, PRETTY_PRINT, COALESCE_ARRAYS));
Link link = rep.getLinkByRel("self");
assertEquals(apptUriBuilder.build(appt.getId()).toString(),
link.getHref());
}
示例6: testSlotRepresentationWithEditLinks
import com.theoryinpractise.halbuilder.api.Representation; //导入方法依赖的package包/类
@Test
public void testSlotRepresentationWithEditLinks() {
Appointment appt = newApptStub(1);
Representation rep = factory.newAppointmentRepresentation(appt);
System.out.println(rep
.toString(HAL_JSON, PRETTY_PRINT, COALESCE_ARRAYS));
Link link = rep.getLinkByRel("edit");
assertEquals(apptUriBuilder.build(appt.getId()).toString(),
link.getHref());
}
示例7: testSlotRepresentationWithSelfLink
import com.theoryinpractise.halbuilder.api.Representation; //导入方法依赖的package包/类
@Test
public void testSlotRepresentationWithSelfLink() {
Slot thisSlot = newSlotStub(2);
Representation rep = factory.newSlotRepresentation(thisSlot,
Optional.<Slot> empty(), Optional.<Slot> empty());
System.out.println(rep
.toString(HAL_JSON, PRETTY_PRINT, COALESCE_ARRAYS));
Link link = rep.getLinkByRel("self");
assertEquals(slotUriBuilder.build(thisSlot.getId()).toString(),
link.getHref());
}