Search in sources :

Example 1 with FactoryConfiguration

use of org.talend.sdk.component.starter.server.model.FactoryConfiguration in project component-runtime by Talend.

the class ProjectResourceTest method configuration.

@Test
void configuration(final WebTarget target) {
    final FactoryConfiguration config = target.path("project/configuration").request(MediaType.APPLICATION_JSON_TYPE).get(FactoryConfiguration.class);
    final String debug = config.toString();
    assertEquals(new HashSet<>(asList("Gradle", "Maven")), new HashSet<>(config.getBuildTypes()), debug);
    assertEquals(new HashMap<String, List<FactoryConfiguration.Facet>>() {

        {
            put("Test", singletonList(new FactoryConfiguration.Facet("Talend Component Kit Testing", "Generates test(s) for each component.")));
            put("Runtime", singletonList(new FactoryConfiguration.Facet("Apache Beam", "Generates some tests using beam runtime instead of Talend Component Kit Testing framework.")));
            put("Libraries", singletonList(new FactoryConfiguration.Facet("WADL Client Generation", "Generates a HTTP client from a WADL.")));
            put("Tool", asList(new FactoryConfiguration.Facet("Codenvy", "Pre-configures the project to be usable with Codenvy."), new FactoryConfiguration.Facet("Travis CI", "Creates a .travis.yml pre-configured for a component build.")));
        }
    }, new HashMap<>(config.getFacets()), debug);
}
Also used : FactoryConfiguration(org.talend.sdk.component.starter.server.model.FactoryConfiguration) Collections.singletonList(java.util.Collections.singletonList) Arrays.asList(java.util.Arrays.asList) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) Resources.resourceFileToString(org.talend.sdk.component.starter.server.service.Resources.resourceFileToString) Test(org.junit.jupiter.api.Test)

Example 2 with FactoryConfiguration

use of org.talend.sdk.component.starter.server.model.FactoryConfiguration in project component-runtime by Talend.

the class ProjectResource method init.

@PostConstruct
private void init() {
    final List<String> buildTypes = new ArrayList<>(generator.getGenerators().keySet());
    buildTypes.sort(String::compareTo);
    final Map<String, List<FactoryConfiguration.Facet>> facets = generator.getFacets().values().stream().collect(toMap(e -> e.category().getHumanName(), e -> new ArrayList<>(singletonList(new FactoryConfiguration.Facet(e.name(), e.description()))), (u, u2) -> {
        if (u == null) {
            return u2;
        }
        u.addAll(u2);
        return u;
    }, TreeMap::new));
    facets.forEach((k, v) -> v.sort(Comparator.comparing(FactoryConfiguration.Facet::getName)));
    configuration = new FactoryConfiguration(buildTypes, facets);
}
Also used : BufferedInputStream(java.io.BufferedInputStream) Produces(javax.ws.rs.Produces) ErrorMessage(org.talend.sdk.component.starter.server.model.ErrorMessage) Path(javax.ws.rs.Path) GithubProject(org.talend.sdk.component.starter.server.model.GithubProject) Collections.singletonList(java.util.Collections.singletonList) MediaType(javax.ws.rs.core.MediaType) Collectors.toMap(java.util.stream.Collectors.toMap) ByteArrayInputStream(java.io.ByteArrayInputStream) Consumes(javax.ws.rs.Consumes) Locale(java.util.Locale) Map(java.util.Map) ENGLISH(java.util.Locale.ENGLISH) ZipEntry(java.util.zip.ZipEntry) ProjectGenerator(org.talend.sdk.component.starter.server.service.ProjectGenerator) Context(javax.ws.rs.core.Context) Providers(javax.ws.rs.ext.Providers) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) Collections.emptyList(java.util.Collections.emptyList) StandardOpenOption(java.nio.file.StandardOpenOption) StreamingOutput(javax.ws.rs.core.StreamingOutput) NullProgressMonitor(org.eclipse.jgit.lib.NullProgressMonitor) Collectors.joining(java.util.stream.Collectors.joining) StandardCharsets(java.nio.charset.StandardCharsets) Base64(java.util.Base64) List(java.util.List) FileUtils(org.eclipse.jgit.util.FileUtils) Slf4j(lombok.extern.slf4j.Slf4j) Response(javax.ws.rs.core.Response) Writer(java.io.Writer) Annotation(java.lang.annotation.Annotation) PostConstruct(javax.annotation.PostConstruct) WebApplicationException(javax.ws.rs.WebApplicationException) ProjectModel(org.talend.sdk.component.starter.server.model.ProjectModel) ApplicationScoped(javax.enterprise.context.ApplicationScoped) CreateProjectRequest(org.talend.sdk.component.starter.server.model.github.CreateProjectRequest) ZipInputStream(java.util.zip.ZipInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) UsernamePasswordCredentialsProvider(org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider) GET(javax.ws.rs.GET) Client(javax.ws.rs.client.Client) Entity.entity(javax.ws.rs.client.Entity.entity) StandardCopyOption(java.nio.file.StandardCopyOption) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) ClientBuilder(javax.ws.rs.client.ClientBuilder) StarterConfiguration(org.talend.sdk.component.starter.server.configuration.StarterConfiguration) FactoryConfiguration(org.talend.sdk.component.starter.server.model.FactoryConfiguration) Collections.emptyMap(java.util.Collections.emptyMap) FormParam(javax.ws.rs.FormParam) POST(javax.ws.rs.POST) Files(java.nio.file.Files) Optional.ofNullable(java.util.Optional.ofNullable) FileWriter(java.io.FileWriter) IOException(java.io.IOException) InputStreamReader(java.io.InputStreamReader) MultivaluedHashMap(javax.ws.rs.core.MultivaluedHashMap) File(java.io.File) CreateProjectResponse(org.talend.sdk.component.starter.server.model.github.CreateProjectResponse) TimeUnit(java.util.concurrent.TimeUnit) Result(org.talend.sdk.component.starter.server.model.Result) Collectors.toList(java.util.stream.Collectors.toList) TreeMap(java.util.TreeMap) APPLICATION_JSON_TYPE(javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE) BufferedReader(java.io.BufferedReader) Git(org.eclipse.jgit.api.Git) Comparator(java.util.Comparator) ProjectRequest(org.talend.sdk.component.starter.server.service.domain.ProjectRequest) InputStream(java.io.InputStream) MessageBodyReader(javax.ws.rs.ext.MessageBodyReader) FactoryConfiguration(org.talend.sdk.component.starter.server.model.FactoryConfiguration) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) ArrayList(java.util.ArrayList) Collectors.toList(java.util.stream.Collectors.toList) PostConstruct(javax.annotation.PostConstruct)

Aggregations

Collections.emptyList (java.util.Collections.emptyList)2 Collections.singletonList (java.util.Collections.singletonList)2 List (java.util.List)2 BufferedInputStream (java.io.BufferedInputStream)1 BufferedReader (java.io.BufferedReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 Writer (java.io.Writer)1 Annotation (java.lang.annotation.Annotation)1 StandardCharsets (java.nio.charset.StandardCharsets)1 Files (java.nio.file.Files)1 StandardCopyOption (java.nio.file.StandardCopyOption)1 StandardOpenOption (java.nio.file.StandardOpenOption)1 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1