use of io.hops.hopsworks.common.featurestore.feature.FeatureGroupFeatureDTO in project hopsworks by logicalclocks.
the class TestFilterController method testFindFilteredFeatureNoId.
@Test
public void testFindFilteredFeatureNoId() throws Exception {
FeatureGroupFeatureDTO featureGroupFeatureDTO = new FeatureGroupFeatureDTO("fg2_ft", "double", "");
Feature result = filterController.findFilteredFeature(featureGroupFeatureDTO, fgLookup, availableFeatureLookup);
Assert.assertEquals("fg2_ft", result.getName());
Assert.assertEquals("fg2", result.getFgAlias(false));
Assert.assertEquals("double", result.getType());
Assert.assertEquals("10.0", result.getDefaultValue());
}
use of io.hops.hopsworks.common.featurestore.feature.FeatureGroupFeatureDTO in project hopsworks by logicalclocks.
the class TestFilterController method testConvertFilter.
@Test
public void testConvertFilter() throws Exception {
FeatureGroupFeatureDTO featureGroupFeatureDTO = new FeatureGroupFeatureDTO("fg2_ft", "double", "");
FilterDTO filter = new FilterDTO(featureGroupFeatureDTO, SqlCondition.EQUALS, "10");
Filter result = filterController.convertFilter(filter, fgLookup, availableFeatureLookup);
Feature feature = result.getFeatures().get(0);
Assert.assertEquals(SqlCondition.EQUALS, result.getCondition());
Assert.assertEquals("10", result.getValue().getValue());
Assert.assertEquals("fg2_ft", feature.getName());
Assert.assertEquals("fg2", feature.getFgAlias(false));
Assert.assertEquals("double", feature.getType());
Assert.assertEquals("10.0", feature.getDefaultValue());
}
use of io.hops.hopsworks.common.featurestore.feature.FeatureGroupFeatureDTO in project hopsworks by logicalclocks.
the class TestFilterController method testValidateFilterLogicDTO.
@Test
public void testValidateFilterLogicDTO() throws Exception {
// tests the validation of a FilterLogicDTO
FeatureGroupFeatureDTO featureGroupFeatureDTO = new FeatureGroupFeatureDTO("fg1_pk", "string", "", true, "10");
FilterDTO filter = new FilterDTO(featureGroupFeatureDTO, SqlCondition.EQUALS, "10");
FilterLogicDTO filterLogicDTO2 = new FilterLogicDTO(SqlFilterLogic.AND);
// case 1
FilterLogicDTO filterLogicDTO = new FilterLogicDTO(SqlFilterLogic.AND);
filterLogicDTO.setLeftFilter(filter);
filterLogicDTO.setLeftLogic(filterLogicDTO2);
thrown.expect(FeaturestoreException.class);
filterController.validateFilterLogicDTO(filterLogicDTO);
// case 2
filterLogicDTO = new FilterLogicDTO(SqlFilterLogic.AND);
filterLogicDTO.setRightFilter(filter);
filterLogicDTO.setRightLogic(filterLogicDTO2);
thrown.expect(FeaturestoreException.class);
filterController.validateFilterLogicDTO(filterLogicDTO);
// case 3
// single and left filter null
filterLogicDTO = new FilterLogicDTO(SqlFilterLogic.SINGLE);
thrown.expect(FeaturestoreException.class);
filterController.validateFilterLogicDTO(filterLogicDTO);
}
use of io.hops.hopsworks.common.featurestore.feature.FeatureGroupFeatureDTO in project hopsworks by logicalclocks.
the class TestFilterController method testFindFilteredFeatureWithIdException.
@Test
public void testFindFilteredFeatureWithIdException() throws Exception {
FeatureGroupFeatureDTO featureGroupFeatureDTO = new FeatureGroupFeatureDTO("not_a_feature_of_fg2", "double", "", 2, true);
thrown.expect(FeaturestoreException.class);
filterController.findFilteredFeature(featureGroupFeatureDTO, fgLookup, availableFeatureLookup);
}
use of io.hops.hopsworks.common.featurestore.feature.FeatureGroupFeatureDTO in project hopsworks by logicalclocks.
the class TestFilterController method testConvertFilterLogic.
@Test
public void testConvertFilterLogic() throws Exception {
// test successful conversion of FilterLogicDTO with one filter and one logic set
FeatureGroupFeatureDTO featureGroupFeatureDTO = new FeatureGroupFeatureDTO("fg1_pk", "string", "");
FilterDTO filter = new FilterDTO(featureGroupFeatureDTO, SqlCondition.EQUALS, "10");
FilterLogicDTO filterLogicDTO2 = new FilterLogicDTO(SqlFilterLogic.AND);
FilterLogicDTO filterLogicDTO = new FilterLogicDTO(SqlFilterLogic.AND);
filterLogicDTO.setLeftFilter(filter);
filterLogicDTO.setRightLogic(filterLogicDTO2);
FilterLogic result = filterController.convertFilterLogic(filterLogicDTO, fgLookup, availableFeatureLookup);
Feature feature = result.getLeftFilter().getFeatures().get(0);
Assert.assertEquals(result.getType(), SqlFilterLogic.AND);
Assert.assertEquals(result.getRightLogic().getType(), SqlFilterLogic.AND);
Assert.assertEquals(SqlCondition.EQUALS, result.getLeftFilter().getCondition());
Assert.assertEquals("10", result.getLeftFilter().getValue().getValue());
Assert.assertEquals("fg1_pk", feature.getName());
Assert.assertEquals("fg1", feature.getFgAlias(false));
Assert.assertEquals("string", feature.getType());
Assert.assertNull(feature.getDefaultValue());
}
Aggregations