org.infinispan.server.test.junit5.InfinispanXSiteServerExtensionBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of infinispan-server-testdriver-junit5-jakarta Show documentation
Show all versions of infinispan-server-testdriver-junit5-jakarta Show documentation
Infinispan Server Test Driver for JUnit 5.x and JakartaEE
package org.infinispan.server.test.junit5;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.infinispan.server.test.core.TestServer;
/**
* Infinispan Server XSite Extension Builder
*
* @author Gustavo Lira
* @since 12.0
*/
public class InfinispanXSiteServerExtensionBuilder {
private final List sites = new ArrayList<>();
public InfinispanXSiteServerExtensionBuilder addSite(String siteName, InfinispanServerExtensionBuilder siteBuilder) {
siteBuilder.site(siteName);
sites.add(siteBuilder);
return this;
}
public InfinispanXSiteServerExtension build() {
Set uniqueSiteName = new HashSet<>();
List testServers = sites.stream()
.map(it -> new TestServer(it.createServerTestConfiguration()))
.peek(testServer -> {
if (!uniqueSiteName.add(testServer.getSiteName())) {
throw new IllegalStateException("Site name already set: " + testServer.getSiteName());
}
})
.collect(Collectors.toList());
return new InfinispanXSiteServerExtension(testServers);
}
}