|
56 | 56 | import java.util.*; |
57 | 57 | import java.util.Map.Entry; |
58 | 58 | import java.util.stream.Collectors; |
| 59 | +import org.apache.commons.lang3.StringUtils; |
59 | 60 | import org.junit.Before; |
60 | 61 | import org.junit.Rule; |
61 | 62 | import org.junit.Test; |
@@ -91,6 +92,7 @@ public class SpecServiceTest { |
91 | 92 |
|
92 | 93 | private SpecService specService; |
93 | 94 | private List<FeatureSet> featureSets; |
| 95 | + private List<FeatureSet> invalidFeatureSets; |
94 | 96 | private List<Feature> features; |
95 | 97 | private List<Store> stores; |
96 | 98 | private Source defaultSource; |
@@ -214,6 +216,12 @@ public void setUp() throws InvalidProtocolBufferException { |
214 | 216 |
|
215 | 217 | specService = |
216 | 218 | new SpecService(featureSetRepository, storeRepository, projectRepository, defaultSource); |
| 219 | + |
| 220 | + Feature invalidFeature1 = TestUtil.CreateFeature("created_timestamp", Enum.INT64); |
| 221 | + FeatureSet invalidFeatureSet1 = |
| 222 | + TestUtil.CreateFeatureSet( |
| 223 | + "f1", "invalid", Arrays.asList(f3e1), Arrays.asList(invalidFeature1)); |
| 224 | + invalidFeatureSets = Arrays.asList(invalidFeatureSet1); |
217 | 225 | } |
218 | 226 |
|
219 | 227 | @Test |
@@ -277,6 +285,22 @@ public void shouldThrowExceptionGivenMissingFeatureSetName() |
277 | 285 | specService.getFeatureSet(GetFeatureSetRequest.newBuilder().build()); |
278 | 286 | } |
279 | 287 |
|
| 288 | + @Test |
| 289 | + public void shouldThrowExceptionGivenReservedFeatureName() throws InvalidProtocolBufferException { |
| 290 | + List<String> reservedNames = |
| 291 | + Arrays.asList("created_timestamp", "event_timestamp", "ingestion_id", "job_id"); |
| 292 | + String reservedNamesString = StringUtils.join(reservedNames, ", "); |
| 293 | + expectedException.expect(IllegalArgumentException.class); |
| 294 | + expectedException.expectMessage( |
| 295 | + String.format( |
| 296 | + "Reserved feature names have been used, which are not allowed. These names include %s." |
| 297 | + + "You've just used an invalid name, %s.", |
| 298 | + reservedNamesString, "created_timestamp")); |
| 299 | + FeatureSet invalidFeatureSet = invalidFeatureSets.get(0); |
| 300 | + |
| 301 | + specService.applyFeatureSet(invalidFeatureSet.toProto()); |
| 302 | + } |
| 303 | + |
280 | 304 | @Test |
281 | 305 | public void shouldThrowExceptionGivenMissingFeatureSet() throws InvalidProtocolBufferException { |
282 | 306 | expectedException.expect(RetrievalException.class); |
|
0 commit comments