mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-16 18:26:16 +01:00
extends LinkEnricher api to append link arrays to the response
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package sonia.scm.api.v2.resources;
|
||||
|
||||
import de.otto.edison.hal.Link;
|
||||
import de.otto.edison.hal.Links;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static de.otto.edison.hal.Links.linkingTo;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class EdisonLinkAppenderTest {
|
||||
|
||||
private Links.Builder builder;
|
||||
private EdisonLinkAppender appender;
|
||||
|
||||
@BeforeEach
|
||||
void prepare() {
|
||||
builder = linkingTo();
|
||||
appender = new EdisonLinkAppender(builder);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldAppendOneLink() {
|
||||
appender.appendOne("self", "https://scm.hitchhiker.com");
|
||||
|
||||
Links links = builder.build();
|
||||
assertThat(links.getLinkBy("self").get().getHref()).isEqualTo("https://scm.hitchhiker.com");
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldAppendMultipleLinks() {
|
||||
appender.arrayBuilder("items")
|
||||
.append("one", "http://one")
|
||||
.append("two", "http://two")
|
||||
.build();
|
||||
|
||||
List<Link> items = builder.build().getLinksBy("items");
|
||||
assertThat(items).hasSize(2);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user