2727import feast .common .it .SimpleCoreClient ;
2828import feast .core .model .Project ;
2929import feast .proto .core .CoreServiceGrpc ;
30+ import feast .proto .core .EntityProto ;
3031import feast .proto .core .FeatureSetProto .FeatureSet ;
32+ import feast .proto .core .FeatureTableProto ;
33+ import feast .proto .types .ValueProto ;
3134import feast .proto .types .ValueProto .ValueType .Enum ;
3235import io .grpc .ManagedChannel ;
3336import io .grpc .ManagedChannelBuilder ;
3437import io .restassured .RestAssured ;
3538import io .restassured .http .ContentType ;
3639import io .restassured .path .json .JsonPath ;
40+ import java .util .Arrays ;
41+ import java .util .HashMap ;
3742import java .util .List ;
3843import org .junit .jupiter .api .BeforeAll ;
3944import org .junit .jupiter .api .BeforeEach ;
@@ -205,19 +210,53 @@ public void listFeatures() {
205210 .body ("features" , aMapWithSize (2 ));
206211 }
207212
213+ @ Test
214+ public void listEntities () {
215+ String uri1 =
216+ UriComponentsBuilder .fromPath ("/api/v2/entities" )
217+ .queryParam ("project" , "default" )
218+ .buildAndExpand ()
219+ .toString ();
220+ String responseBody =
221+ get (uri1 )
222+ .then ()
223+ .log ()
224+ .everything ()
225+ .assertThat ()
226+ .contentType (ContentType .JSON )
227+ .extract ()
228+ .response ()
229+ .getBody ()
230+ .asString ();
231+ List <String > entityList = JsonPath .from (responseBody ).getList ("entities" );
232+ assertEquals (entityList .size (), 2 );
233+ }
234+
235+ @ Test
236+ public void listFeatureTables () {
237+ String uri1 =
238+ UriComponentsBuilder .fromPath ("/api/v2/feature-tables" )
239+ .queryParam ("project" , "default" )
240+ .buildAndExpand ()
241+ .toString ();
242+ String responseBody =
243+ get (uri1 )
244+ .then ()
245+ .log ()
246+ .everything ()
247+ .assertThat ()
248+ .contentType (ContentType .JSON )
249+ .extract ()
250+ .response ()
251+ .getBody ()
252+ .asString ();
253+ List <String > featureTableList = JsonPath .from (responseBody ).getList ("tables" );
254+ assertEquals (featureTableList .size (), 1 );
255+ }
256+
208257 @ BeforeEach
209- private void createFakeFeatureSets () {
210- // spec:
211- // name: merchant_ratings
212- // entities:
213- // - name: merchant_id
214- // valueType: STRING
215- // features:
216- // - name: average_rating
217- // valueType: DOUBLE
218- // - name: total_ratings
219- // valueType: INT64
220- // project: default
258+ private void createSpecs () {
259+ // Apply feature sets
221260 FeatureSet merchantFeatureSet =
222261 DataGenerator .createFeatureSet (
223262 DataGenerator .getDefaultSource (),
@@ -227,17 +266,6 @@ private void createFakeFeatureSets() {
227266 ImmutableMap .of ("average_rating" , Enum .DOUBLE , "total_ratings" , Enum .INT64 ));
228267 apiClient .simpleApplyFeatureSet (merchantFeatureSet );
229268
230- // spec:
231- // name: another_merchant_ratings
232- // entities:
233- // - name: merchant_id
234- // valueType: STRING
235- // features:
236- // - name: another_average_rating
237- // valueType: DOUBLE
238- // - name: another_total_ratings
239- // valueType: INT64
240- // project: default
241269 FeatureSet anotherMerchantFeatureSet =
242270 DataGenerator .createFeatureSet (
243271 DataGenerator .getDefaultSource (),
@@ -249,17 +277,6 @@ private void createFakeFeatureSets() {
249277 "another_total_ratings" , Enum .INT64 ));
250278 apiClient .simpleApplyFeatureSet (anotherMerchantFeatureSet );
251279
252- // spec:
253- // name: yet_another_merchant_feature_set
254- // entities:
255- // - name: merchant_id
256- // valueType: STRING
257- // features:
258- // - name: merchant_prop1
259- // valueType: BOOL
260- // - name: merchant_prop2
261- // valueType: FLOAT
262- // project: merchant
263280 FeatureSet yetAnotherMerchantFeatureSet =
264281 DataGenerator .createFeatureSet (
265282 DataGenerator .getDefaultSource (),
@@ -268,6 +285,42 @@ private void createFakeFeatureSets() {
268285 ImmutableMap .of ("merchant_id" , Enum .STRING ),
269286 ImmutableMap .of ("merchant_prop1" , Enum .BOOL , "merchant_prop2" , Enum .FLOAT ));
270287 apiClient .simpleApplyFeatureSet (yetAnotherMerchantFeatureSet );
288+
289+ // Apply entities
290+ EntityProto .EntitySpecV2 entitySpec1 =
291+ DataGenerator .createEntitySpecV2 (
292+ "entity1" ,
293+ "Entity 1 description" ,
294+ ValueProto .ValueType .Enum .STRING ,
295+ avro .shaded .com .google .common .collect .ImmutableMap .of ("label_key" , "label_value" ));
296+ EntityProto .EntitySpecV2 entitySpec2 =
297+ DataGenerator .createEntitySpecV2 (
298+ "entity2" ,
299+ "Entity 2 description" ,
300+ ValueProto .ValueType .Enum .STRING ,
301+ avro .shaded .com .google .common .collect .ImmutableMap .of ("label_key2" , "label_value2" ));
302+ apiClient .simpleApplyEntity ("default" , entitySpec1 );
303+ apiClient .simpleApplyEntity ("default" , entitySpec2 );
304+
305+ // Apply feature table
306+ FeatureTableProto .FeatureTableSpec featureTableSpec =
307+ DataGenerator .createFeatureTableSpec (
308+ "featuretable1" ,
309+ Arrays .asList ("entity1" , "entity2" ),
310+ new HashMap <>() {
311+ {
312+ put ("feature1" , ValueProto .ValueType .Enum .STRING );
313+ put ("feature2" , ValueProto .ValueType .Enum .FLOAT );
314+ }
315+ },
316+ 7200 ,
317+ ImmutableMap .of ("feat_key2" , "feat_value2" ))
318+ .toBuilder ()
319+ .setBatchSource (
320+ DataGenerator .createFileDataSourceSpec ("file:///path/to/file" , "ts_col" , "" ))
321+ .build ();
322+ apiClient .applyFeatureTable ("default" , featureTableSpec );
323+
271324 RestAssured .port = port ;
272325 }
273326}
0 commit comments