4040import io .grpc .StatusRuntimeException ;
4141import java .util .*;
4242import java .util .stream .IntStream ;
43-
44- import org .apache .commons .lang3 .ArrayUtils ;
4543import org .apache .commons .lang3 .tuple .Triple ;
4644import org .junit .jupiter .api .BeforeAll ;
4745import org .junit .jupiter .api .BeforeEach ;
@@ -86,37 +84,39 @@ public void initState() {
8684 apiClient .simpleApplyEntity ("default" , entitySpec1 );
8785 apiClient .simpleApplyEntity ("default" , entitySpec2 );
8886
89- example1 = DataGenerator .createFeatureTableSpec (
90- "featuretable1" ,
91- Arrays .asList ("entity1" , "entity2" ),
92- new HashMap <>() {
93- {
94- put ("feature1" , ValueProto .ValueType .Enum .STRING );
95- put ("feature2" , ValueProto .ValueType .Enum .FLOAT );
96- }
97- },
98- 7200 ,
99- ImmutableMap .of ("feat_key2" , "feat_value2" ))
100- .toBuilder ()
101- .setBatchSource (
102- DataGenerator .createFileDataSourceSpec ("file:///path/to/file" , "ts_col" , "" ))
103- .build ();
104-
105- example2 = DataGenerator .createFeatureTableSpec (
106- "featuretable2" ,
107- Arrays .asList ("entity1" , "entity2" ),
108- new HashMap <>() {
109- {
110- put ("feature3" , ValueProto .ValueType .Enum .STRING );
111- put ("feature4" , ValueProto .ValueType .Enum .FLOAT );
112- }
113- },
114- 7200 ,
115- ImmutableMap .of ("feat_key4" , "feat_value4" ))
116- .toBuilder ()
117- .setBatchSource (
118- DataGenerator .createFileDataSourceSpec ("file:///path/to/file" , "ts_col" , "" ))
119- .build ();
87+ example1 =
88+ DataGenerator .createFeatureTableSpec (
89+ "featuretable1" ,
90+ Arrays .asList ("entity1" , "entity2" ),
91+ new HashMap <>() {
92+ {
93+ put ("feature1" , ValueProto .ValueType .Enum .STRING );
94+ put ("feature2" , ValueProto .ValueType .Enum .FLOAT );
95+ }
96+ },
97+ 7200 ,
98+ ImmutableMap .of ("feat_key2" , "feat_value2" ))
99+ .toBuilder ()
100+ .setBatchSource (
101+ DataGenerator .createFileDataSourceSpec ("file:///path/to/file" , "ts_col" , "" ))
102+ .build ();
103+
104+ example2 =
105+ DataGenerator .createFeatureTableSpec (
106+ "featuretable2" ,
107+ Arrays .asList ("entity1" , "entity2" ),
108+ new HashMap <>() {
109+ {
110+ put ("feature3" , ValueProto .ValueType .Enum .STRING );
111+ put ("feature4" , ValueProto .ValueType .Enum .FLOAT );
112+ }
113+ },
114+ 7200 ,
115+ ImmutableMap .of ("feat_key4" , "feat_value4" ))
116+ .toBuilder ()
117+ .setBatchSource (
118+ DataGenerator .createFileDataSourceSpec ("file:///path/to/file" , "ts_col" , "" ))
119+ .build ();
120120
121121 apiClient .applyFeatureTable ("default" , example1 );
122122 apiClient .applyFeatureTable ("default" , example2 );
@@ -536,7 +536,8 @@ public void shouldFilterFeaturesByEntitiesAndLabels() {
536536 @ Nested
537537 public class ApplyFeatureTable {
538538 private FeatureTableSpec getTestSpec () {
539- return example1 .toBuilder ()
539+ return example1
540+ .toBuilder ()
540541 .setName ("apply_test" )
541542 .setStreamSource (
542543 DataGenerator .createKafkaDataSourceSpec (
@@ -556,16 +557,17 @@ public void shouldApplyNewValidTable() {
556557 public void shouldUpdateExistingTableWithValidSpec () {
557558 FeatureTableProto .FeatureTable table = apiClient .applyFeatureTable ("default" , getTestSpec ());
558559
559- FeatureTableSpec updatedSpec = getTestSpec ().toBuilder ()
560- .clearFeatures ()
561- .addFeatures (
562- DataGenerator .createFeatureSpecV2 ("feature5" , ValueProto .ValueType .Enum .FLOAT , ImmutableMap .of ())
563- )
564- .setStreamSource (
565- DataGenerator .createKafkaDataSourceSpec (
566- "localhost:9092" , "new_topic" , "new.class" , "ts_col" )
567- )
568- .build ();
560+ FeatureTableSpec updatedSpec =
561+ getTestSpec ()
562+ .toBuilder ()
563+ .clearFeatures ()
564+ .addFeatures (
565+ DataGenerator .createFeatureSpecV2 (
566+ "feature5" , ValueProto .ValueType .Enum .FLOAT , ImmutableMap .of ()))
567+ .setStreamSource (
568+ DataGenerator .createKafkaDataSourceSpec (
569+ "localhost:9092" , "new_topic" , "new.class" , "ts_col" ))
570+ .build ();
569571
570572 FeatureTableProto .FeatureTable updatedTable =
571573 apiClient .applyFeatureTable ("default" , updatedSpec );
@@ -576,10 +578,8 @@ public void shouldUpdateExistingTableWithValidSpec() {
576578
577579 @ Test
578580 public void shouldUpdateFeatureTableOnEntityChange () {
579- FeatureTableProto .FeatureTableSpec updatedSpec = getTestSpec ().toBuilder ()
580- .clearEntities ()
581- .addEntities ("entity1" )
582- .build ();
581+ FeatureTableProto .FeatureTableSpec updatedSpec =
582+ getTestSpec ().toBuilder ().clearEntities ().addEntities ("entity1" ).build ();
583583
584584 FeatureTableProto .FeatureTable updatedTable =
585585 apiClient .applyFeatureTable ("default" , updatedSpec );
@@ -589,9 +589,11 @@ public void shouldUpdateFeatureTableOnEntityChange() {
589589
590590 @ Test
591591 public void shouldUpdateFeatureTableOnMaxAgeChange () {
592- FeatureTableProto .FeatureTableSpec updatedSpec = getTestSpec ().toBuilder ()
593- .setMaxAge (Duration .newBuilder ().setSeconds (600 ).build ())
594- .build ();
592+ FeatureTableProto .FeatureTableSpec updatedSpec =
593+ getTestSpec ()
594+ .toBuilder ()
595+ .setMaxAge (Duration .newBuilder ().setSeconds (600 ).build ())
596+ .build ();
595597
596598 FeatureTableProto .FeatureTable updatedTable =
597599 apiClient .applyFeatureTable ("default" , updatedSpec );
@@ -601,14 +603,20 @@ public void shouldUpdateFeatureTableOnMaxAgeChange() {
601603
602604 @ Test
603605 public void shouldUpdateFeatureTableOnFeatureTypeChange () {
604- int featureIdx = IntStream .range (0 , getTestSpec ().getFeaturesCount ())
605- .filter (i -> getTestSpec ().getFeatures (i ).getName ().equals ("feature2" ))
606- .findFirst ().orElse (-1 );
607-
608- FeatureTableProto .FeatureTableSpec updatedSpec = getTestSpec ().toBuilder ()
609- .setFeatures (featureIdx ,
610- DataGenerator .createFeatureSpecV2 ("feature2" , ValueProto .ValueType .Enum .STRING_LIST , ImmutableMap .of ()))
611- .build ();
606+ int featureIdx =
607+ IntStream .range (0 , getTestSpec ().getFeaturesCount ())
608+ .filter (i -> getTestSpec ().getFeatures (i ).getName ().equals ("feature2" ))
609+ .findFirst ()
610+ .orElse (-1 );
611+
612+ FeatureTableProto .FeatureTableSpec updatedSpec =
613+ getTestSpec ()
614+ .toBuilder ()
615+ .setFeatures (
616+ featureIdx ,
617+ DataGenerator .createFeatureSpecV2 (
618+ "feature2" , ValueProto .ValueType .Enum .STRING_LIST , ImmutableMap .of ()))
619+ .build ();
612620
613621 FeatureTableProto .FeatureTable updatedTable =
614622 apiClient .applyFeatureTable ("default" , updatedSpec );
@@ -618,11 +626,13 @@ public void shouldUpdateFeatureTableOnFeatureTypeChange() {
618626
619627 @ Test
620628 public void shouldUpdateFeatureTableOnFeatureAddition () {
621- FeatureTableProto .FeatureTableSpec updatedSpec = getTestSpec ().toBuilder ()
622- .addFeatures (
623- DataGenerator .createFeatureSpecV2 ("feature6" , ValueProto .ValueType .Enum .FLOAT , ImmutableMap .of ())
624- )
625- .build ();
629+ FeatureTableProto .FeatureTableSpec updatedSpec =
630+ getTestSpec ()
631+ .toBuilder ()
632+ .addFeatures (
633+ DataGenerator .createFeatureSpecV2 (
634+ "feature6" , ValueProto .ValueType .Enum .FLOAT , ImmutableMap .of ()))
635+ .build ();
626636
627637 FeatureTableProto .FeatureTable updatedTable =
628638 apiClient .applyFeatureTable ("default" , updatedSpec );
0 commit comments