mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 17:26:22 +01:00
implemented LinkEnricher registration via Enrich annotation
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
package sonia.scm.api.v2.resources;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static org.assertj.core.api.Java6Assertions.assertThat;
|
||||
|
||||
class LinkEnricherAutoRegistrationTest {
|
||||
|
||||
@Test
|
||||
void shouldRegisterAllAvailableLinkEnrichers() {
|
||||
LinkEnricher one = new One();
|
||||
LinkEnricher two = new Two();
|
||||
LinkEnricher three = new Three();
|
||||
LinkEnricher four = new Four();
|
||||
Set<LinkEnricher> enrichers = ImmutableSet.of(one, two, three, four);
|
||||
|
||||
LinkEnricherRegistry registry = new LinkEnricherRegistry();
|
||||
|
||||
LinkEnricherAutoRegistration autoRegistration = new LinkEnricherAutoRegistration(registry, enrichers);
|
||||
autoRegistration.contextInitialized(null);
|
||||
|
||||
assertThat(registry.allByType(String.class)).containsOnly(one, two);
|
||||
assertThat(registry.allByType(Integer.class)).containsOnly(three);
|
||||
}
|
||||
|
||||
@Enrich(String.class)
|
||||
public static class One implements LinkEnricher {
|
||||
|
||||
@Override
|
||||
public void enrich(LinkEnricherContext context, LinkAppender appender) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Enrich(String.class)
|
||||
public static class Two implements LinkEnricher {
|
||||
|
||||
@Override
|
||||
public void enrich(LinkEnricherContext context, LinkAppender appender) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Enrich(Integer.class)
|
||||
public static class Three implements LinkEnricher {
|
||||
|
||||
@Override
|
||||
public void enrich(LinkEnricherContext context, LinkAppender appender) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static class Four implements LinkEnricher {
|
||||
|
||||
@Override
|
||||
public void enrich(LinkEnricherContext context, LinkAppender appender) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user