Search in sources :

Example 41 with Service

use of io.github.microcks.domain.Service in project microcks by microcks.

the class AsyncAPIImporter method getServiceDefinitions.

@Override
public List<Service> getServiceDefinitions() throws MockRepositoryImportException {
    List<Service> result = new ArrayList<>();
    // Build a new service.
    Service service = new Service();
    service.setName(spec.path("info").path("title").asText());
    service.setVersion(spec.path("info").path("version").asText());
    service.setType(ServiceType.EVENT);
    // Complete metadata if specified via extension.
    if (spec.path("info").has(MetadataExtensions.MICROCKS_EXTENSION)) {
        Metadata metadata = new Metadata();
        MetadataExtractor.completeMetadata(metadata, spec.path("info").path(MetadataExtensions.MICROCKS_EXTENSION));
        service.setMetadata(metadata);
    }
    // Then build its operations.
    service.setOperations(extractOperations());
    result.add(service);
    return result;
}
Also used : ArrayList(java.util.ArrayList) Metadata(io.github.microcks.domain.Metadata) Service(io.github.microcks.domain.Service)

Example 42 with Service

use of io.github.microcks.domain.Service in project microcks by microcks.

the class ServiceRepositoryImpl method findByLabelsAndNameLike.

@Override
public List<Service> findByLabelsAndNameLike(Map<String, String> labels, String name) {
    Query query = new Query(Criteria.where("name").regex(name, "i"));
    for (String labelKey : labels.keySet()) {
        query.addCriteria(Criteria.where("metadata.labels." + labelKey).is(labels.get(labelKey)));
    }
    List<Service> results = template.find(query, Service.class);
    return results;
}
Also used : Query(org.springframework.data.mongodb.core.query.Query) Service(io.github.microcks.domain.Service)

Aggregations

Service (io.github.microcks.domain.Service)42 MockRepositoryImportException (io.github.microcks.util.MockRepositoryImportException)18 Operation (io.github.microcks.domain.Operation)15 Test (org.junit.Test)15 Resource (io.github.microcks.domain.Resource)12 IOException (java.io.IOException)10 ResponseEntity (org.springframework.http.ResponseEntity)7 Response (io.github.microcks.domain.Response)6 File (java.io.File)6 ArrayList (java.util.ArrayList)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 Exchange (io.github.microcks.domain.Exchange)4 Request (io.github.microcks.domain.Request)4 RequestResponsePair (io.github.microcks.domain.RequestResponsePair)4 UnidirectionalEvent (io.github.microcks.domain.UnidirectionalEvent)4 List (java.util.List)4 HttpHeaders (org.springframework.http.HttpHeaders)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 Header (io.github.microcks.domain.Header)3 Metadata (io.github.microcks.domain.Metadata)3