Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
Signed-off-by: Oleksii Moskalenko <moskalenko.alexey@gmail.com>
  • Loading branch information
pyalex committed Dec 1, 2020
1 parent a0102b2 commit 1a4d38a
Showing 1 changed file with 74 additions and 64 deletions.
138 changes: 74 additions & 64 deletions core/src/test/java/feast/core/service/SpecServiceIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
import io.grpc.StatusRuntimeException;
import java.util.*;
import java.util.stream.IntStream;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.tuple.Triple;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -86,37 +84,39 @@ public void initState() {
apiClient.simpleApplyEntity("default", entitySpec1);
apiClient.simpleApplyEntity("default", entitySpec2);

example1 = DataGenerator.createFeatureTableSpec(
"featuretable1",
Arrays.asList("entity1", "entity2"),
new HashMap<>() {
{
put("feature1", ValueProto.ValueType.Enum.STRING);
put("feature2", ValueProto.ValueType.Enum.FLOAT);
}
},
7200,
ImmutableMap.of("feat_key2", "feat_value2"))
.toBuilder()
.setBatchSource(
DataGenerator.createFileDataSourceSpec("file:///path/to/file", "ts_col", ""))
.build();

example2 = DataGenerator.createFeatureTableSpec(
"featuretable2",
Arrays.asList("entity1", "entity2"),
new HashMap<>() {
{
put("feature3", ValueProto.ValueType.Enum.STRING);
put("feature4", ValueProto.ValueType.Enum.FLOAT);
}
},
7200,
ImmutableMap.of("feat_key4", "feat_value4"))
.toBuilder()
.setBatchSource(
DataGenerator.createFileDataSourceSpec("file:///path/to/file", "ts_col", ""))
.build();
example1 =
DataGenerator.createFeatureTableSpec(
"featuretable1",
Arrays.asList("entity1", "entity2"),
new HashMap<>() {
{
put("feature1", ValueProto.ValueType.Enum.STRING);
put("feature2", ValueProto.ValueType.Enum.FLOAT);
}
},
7200,
ImmutableMap.of("feat_key2", "feat_value2"))
.toBuilder()
.setBatchSource(
DataGenerator.createFileDataSourceSpec("file:///path/to/file", "ts_col", ""))
.build();

example2 =
DataGenerator.createFeatureTableSpec(
"featuretable2",
Arrays.asList("entity1", "entity2"),
new HashMap<>() {
{
put("feature3", ValueProto.ValueType.Enum.STRING);
put("feature4", ValueProto.ValueType.Enum.FLOAT);
}
},
7200,
ImmutableMap.of("feat_key4", "feat_value4"))
.toBuilder()
.setBatchSource(
DataGenerator.createFileDataSourceSpec("file:///path/to/file", "ts_col", ""))
.build();

apiClient.applyFeatureTable("default", example1);
apiClient.applyFeatureTable("default", example2);
Expand Down Expand Up @@ -536,7 +536,8 @@ public void shouldFilterFeaturesByEntitiesAndLabels() {
@Nested
public class ApplyFeatureTable {
private FeatureTableSpec getTestSpec() {
return example1.toBuilder()
return example1
.toBuilder()
.setName("apply_test")
.setStreamSource(
DataGenerator.createKafkaDataSourceSpec(
Expand All @@ -556,16 +557,17 @@ public void shouldApplyNewValidTable() {
public void shouldUpdateExistingTableWithValidSpec() {
FeatureTableProto.FeatureTable table = apiClient.applyFeatureTable("default", getTestSpec());

FeatureTableSpec updatedSpec = getTestSpec().toBuilder()
.clearFeatures()
.addFeatures(
DataGenerator.createFeatureSpecV2("feature5", ValueProto.ValueType.Enum.FLOAT, ImmutableMap.of())
)
.setStreamSource(
DataGenerator.createKafkaDataSourceSpec(
"localhost:9092", "new_topic", "new.class", "ts_col")
)
.build();
FeatureTableSpec updatedSpec =
getTestSpec()
.toBuilder()
.clearFeatures()
.addFeatures(
DataGenerator.createFeatureSpecV2(
"feature5", ValueProto.ValueType.Enum.FLOAT, ImmutableMap.of()))
.setStreamSource(
DataGenerator.createKafkaDataSourceSpec(
"localhost:9092", "new_topic", "new.class", "ts_col"))
.build();

FeatureTableProto.FeatureTable updatedTable =
apiClient.applyFeatureTable("default", updatedSpec);
Expand All @@ -576,10 +578,8 @@ public void shouldUpdateExistingTableWithValidSpec() {

@Test
public void shouldUpdateFeatureTableOnEntityChange() {
FeatureTableProto.FeatureTableSpec updatedSpec = getTestSpec().toBuilder()
.clearEntities()
.addEntities("entity1")
.build();
FeatureTableProto.FeatureTableSpec updatedSpec =
getTestSpec().toBuilder().clearEntities().addEntities("entity1").build();

FeatureTableProto.FeatureTable updatedTable =
apiClient.applyFeatureTable("default", updatedSpec);
Expand All @@ -589,9 +589,11 @@ public void shouldUpdateFeatureTableOnEntityChange() {

@Test
public void shouldUpdateFeatureTableOnMaxAgeChange() {
FeatureTableProto.FeatureTableSpec updatedSpec = getTestSpec().toBuilder()
.setMaxAge(Duration.newBuilder().setSeconds(600).build())
.build();
FeatureTableProto.FeatureTableSpec updatedSpec =
getTestSpec()
.toBuilder()
.setMaxAge(Duration.newBuilder().setSeconds(600).build())
.build();

FeatureTableProto.FeatureTable updatedTable =
apiClient.applyFeatureTable("default", updatedSpec);
Expand All @@ -601,14 +603,20 @@ public void shouldUpdateFeatureTableOnMaxAgeChange() {

@Test
public void shouldUpdateFeatureTableOnFeatureTypeChange() {
int featureIdx = IntStream.range(0, getTestSpec().getFeaturesCount())
.filter(i -> getTestSpec().getFeatures(i).getName().equals("feature2"))
.findFirst().orElse(-1);

FeatureTableProto.FeatureTableSpec updatedSpec = getTestSpec().toBuilder()
.setFeatures(featureIdx,
DataGenerator.createFeatureSpecV2("feature2", ValueProto.ValueType.Enum.STRING_LIST, ImmutableMap.of()))
.build();
int featureIdx =
IntStream.range(0, getTestSpec().getFeaturesCount())
.filter(i -> getTestSpec().getFeatures(i).getName().equals("feature2"))
.findFirst()
.orElse(-1);

FeatureTableProto.FeatureTableSpec updatedSpec =
getTestSpec()
.toBuilder()
.setFeatures(
featureIdx,
DataGenerator.createFeatureSpecV2(
"feature2", ValueProto.ValueType.Enum.STRING_LIST, ImmutableMap.of()))
.build();

FeatureTableProto.FeatureTable updatedTable =
apiClient.applyFeatureTable("default", updatedSpec);
Expand All @@ -618,11 +626,13 @@ public void shouldUpdateFeatureTableOnFeatureTypeChange() {

@Test
public void shouldUpdateFeatureTableOnFeatureAddition() {
FeatureTableProto.FeatureTableSpec updatedSpec = getTestSpec().toBuilder()
.addFeatures(
DataGenerator.createFeatureSpecV2("feature6", ValueProto.ValueType.Enum.FLOAT, ImmutableMap.of())
)
.build();
FeatureTableProto.FeatureTableSpec updatedSpec =
getTestSpec()
.toBuilder()
.addFeatures(
DataGenerator.createFeatureSpecV2(
"feature6", ValueProto.ValueType.Enum.FLOAT, ImmutableMap.of()))
.build();

FeatureTableProto.FeatureTable updatedTable =
apiClient.applyFeatureTable("default", updatedSpec);
Expand Down

0 comments on commit 1a4d38a

Please sign in to comment.