Skip to content

Commit

Permalink
assert for the actual applied labels (feast-dev#740)
Browse files Browse the repository at this point in the history
Co-authored-by: Krzysztof Suwinski <[email protected]>
  • Loading branch information
2 people authored and chi zhang committed Jun 11, 2020
1 parent 36f9fbb commit 8ba331f
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions core/src/test/java/feast/core/service/SpecServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,6 @@ public void applyFeatureSetShouldFailWhenProjectIsArchived()

@Test
public void applyFeatureSetShouldAcceptFeatureLabels() throws InvalidProtocolBufferException {
List<EntitySpec> entitySpecs = new ArrayList<>();
entitySpecs.add(EntitySpec.newBuilder().setName("entity1").setValueType(Enum.INT64).build());

Map<String, String> featureLabels0 =
new HashMap<>() {
Expand Down Expand Up @@ -583,7 +581,6 @@ public void applyFeatureSetShouldAcceptFeatureLabels() throws InvalidProtocolBuf
FeatureSetSpec.newBuilder()
.setProject("project1")
.setName("featureSetWithConstraints")
.addAllEntities(entitySpecs)
.addAllFeatures(featureSpecs)
.build();
FeatureSetProto.FeatureSet featureSet =
Expand All @@ -592,22 +589,15 @@ public void applyFeatureSetShouldAcceptFeatureLabels() throws InvalidProtocolBuf
ApplyFeatureSetResponse applyFeatureSetResponse = specService.applyFeatureSet(featureSet);
FeatureSetSpec appliedFeatureSetSpec = applyFeatureSetResponse.getFeatureSet().getSpec();

// appliedEntitySpecs needs to be sorted because the list returned by specService may not
// follow the order in the request
List<EntitySpec> appliedEntitySpecs = new ArrayList<>(appliedFeatureSetSpec.getEntitiesList());
appliedEntitySpecs.sort(Comparator.comparing(EntitySpec::getName));

// appliedFeatureSpecs needs to be sorted because the list returned by specService may not
// follow the order in the request
List<FeatureSpec> appliedFeatureSpecs =
new ArrayList<>(appliedFeatureSetSpec.getFeaturesList());
appliedFeatureSpecs.sort(Comparator.comparing(FeatureSpec::getName));

var featureSpecsLabels =
featureSpecs.stream().map(e -> e.getLabelsMap()).collect(Collectors.toList());
assertEquals(appliedEntitySpecs, entitySpecs);
assertEquals(appliedFeatureSpecs, featureSpecs);
assertEquals(featureSpecsLabels, featureLabels);
var appliedFeatureSpecsLabels =
appliedFeatureSpecs.stream().map(e -> e.getLabelsMap()).collect(Collectors.toList());
assertEquals(appliedFeatureSpecsLabels, featureLabels);
}

@Test
Expand Down

0 comments on commit 8ba331f

Please sign in to comment.