Search in sources :

Example 21 with DatasetModuleMeta

use of co.cask.cdap.proto.DatasetModuleMeta 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(), Iterables.transform(actualTypes, new Function<DatasetTypeMeta, String>() {

        @Nullable
        @Override
        public String apply(@Nullable DatasetTypeMeta input) {
            return input == null ? null : input.getName();
        }
    })));
    for (DatasetTypeMeta typeMeta : actualTypes) {
        verify(typeMeta, typeMeta.getName(), typeDependencies.get(typeMeta.getName()));
    }
}
Also used : DatasetModuleMeta(co.cask.cdap.proto.DatasetModuleMeta) DatasetTypeMeta(co.cask.cdap.proto.DatasetTypeMeta) Nullable(javax.annotation.Nullable) HashSet(java.util.HashSet)

Aggregations

DatasetModuleMeta (co.cask.cdap.proto.DatasetModuleMeta)21 DatasetModuleId (co.cask.cdap.proto.id.DatasetModuleId)6 DatasetModuleNotFoundException (co.cask.cdap.common.DatasetModuleNotFoundException)5 DatasetTypeMeta (co.cask.cdap.proto.DatasetTypeMeta)5 DatasetTypeMDS (co.cask.cdap.data2.datafabric.dataset.service.mds.DatasetTypeMDS)4 Principal (co.cask.cdap.proto.security.Principal)4 UnauthorizedException (co.cask.cdap.security.spi.authorization.UnauthorizedException)4 IOException (java.io.IOException)4 Collection (java.util.Collection)4 HashSet (java.util.HashSet)4 RowMaker (co.cask.cdap.cli.util.RowMaker)3 Table (co.cask.cdap.cli.util.table.Table)3 DatasetInstanceMDS (co.cask.cdap.data2.datafabric.dataset.service.mds.DatasetInstanceMDS)3 DatasetModuleConflictException (co.cask.cdap.data2.datafabric.dataset.type.DatasetModuleConflictException)3 TypeConflictException (co.cask.cdap.data2.dataset2.TypeConflictException)3 File (java.io.File)3 Location (org.apache.twill.filesystem.Location)3 Test (org.junit.Test)3 DatasetSpecification (co.cask.cdap.api.dataset.DatasetSpecification)2 ConflictException (co.cask.cdap.common.ConflictException)2