Search in sources :

Example 1 with ObjectResponse

use of io.cdap.common.http.ObjectResponse in project cdap by caskdata.

the class DatasetTypeHandlerTest method verifyAll.

private void verifyAll(Set<DatasetModuleMeta> expectedModules, Map<String, List<String>> typeDependencies) throws IOException {
    Set<DatasetModuleMeta> actualModules = new HashSet<>(getModules().getResponseObject());
    Assert.assertEquals(expectedModules, actualModules);
    for (DatasetModuleMeta expectedModule : expectedModules) {
        ObjectResponse<DatasetModuleMeta> response = getModule(expectedModule.getName());
        Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
        Assert.assertEquals(expectedModule, response.getResponseObject());
        for (String type : expectedModule.getTypes()) {
            ObjectResponse<DatasetTypeMeta> typeResponse = getType(type);
            Assert.assertEquals(HttpStatus.SC_OK, typeResponse.getResponseCode());
            verify(typeResponse.getResponseObject(), type, typeDependencies.get(type));
        }
    }
    List<DatasetTypeMeta> actualTypes = getTypes().getResponseObject();
    Assert.assertEquals(actualTypes.size(), typeDependencies.size());
    Assert.assertTrue(Iterables.elementsEqual(typeDependencies.keySet(), actualTypes.stream().map(input -> input == null ? null : input.getName()).collect(Collectors.toList())));
    for (DatasetTypeMeta typeMeta : actualTypes) {
        verify(typeMeta, typeMeta.getName(), typeDependencies.get(typeMeta.getName()));
    }
}
Also used : Iterables(com.google.common.collect.Iterables) TypeToken(com.google.gson.reflect.TypeToken) BeforeClass(org.junit.BeforeClass) NamespaceId(io.cdap.cdap.proto.id.NamespaceId) Location(org.apache.twill.filesystem.Location) DatasetTypeMeta(io.cdap.cdap.proto.DatasetTypeMeta) DatasetInstanceConfiguration(io.cdap.cdap.proto.DatasetInstanceConfiguration) HttpResponse(io.cdap.common.http.HttpResponse) HttpStatus(org.apache.http.HttpStatus) HashMap(java.util.HashMap) ObjectResponse(io.cdap.common.http.ObjectResponse) HashSet(java.util.HashSet) ImmutableList(com.google.common.collect.ImmutableList) Map(java.util.Map) DatasetTypeId(io.cdap.cdap.proto.id.DatasetTypeId) HttpRequests(io.cdap.common.http.HttpRequests) DatasetModuleId(io.cdap.cdap.proto.id.DatasetModuleId) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) DatasetModuleMeta(io.cdap.cdap.proto.DatasetModuleMeta) Collection(java.util.Collection) Set(java.util.Set) Test(org.junit.Test) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) File(java.io.File) List(java.util.List) Assert(org.junit.Assert) Collections(java.util.Collections) HttpRequest(io.cdap.common.http.HttpRequest) DatasetModuleMeta(io.cdap.cdap.proto.DatasetModuleMeta) DatasetTypeMeta(io.cdap.cdap.proto.DatasetTypeMeta) HashSet(java.util.HashSet)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Iterables (com.google.common.collect.Iterables)1 Sets (com.google.common.collect.Sets)1 TypeToken (com.google.gson.reflect.TypeToken)1 DatasetInstanceConfiguration (io.cdap.cdap.proto.DatasetInstanceConfiguration)1 DatasetModuleMeta (io.cdap.cdap.proto.DatasetModuleMeta)1 DatasetTypeMeta (io.cdap.cdap.proto.DatasetTypeMeta)1 DatasetModuleId (io.cdap.cdap.proto.id.DatasetModuleId)1 DatasetTypeId (io.cdap.cdap.proto.id.DatasetTypeId)1 NamespaceId (io.cdap.cdap.proto.id.NamespaceId)1 HttpRequest (io.cdap.common.http.HttpRequest)1 HttpRequests (io.cdap.common.http.HttpRequests)1 HttpResponse (io.cdap.common.http.HttpResponse)1 ObjectResponse (io.cdap.common.http.ObjectResponse)1 File (java.io.File)1 IOException (java.io.IOException)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1