-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: properly validate that aspects can only be of type record (#144)
* properly validate that aspects can only be of type record * add more tests to validation util * remove union test * change name of method
- Loading branch information
1 parent
41bd6b9
commit d2d88bb
Showing
12 changed files
with
76 additions
and
9 deletions.
There are no files selected for viewing
4 changes: 1 addition & 3 deletions
4
dao-api/src/main/pegasus/com/linkedin/metadata/dummy/DummyAspect.pdl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
namespace com.linkedin.metadata.dummy | ||
|
||
import com.linkedin.common.Urn | ||
|
||
/** | ||
* Not to be used | ||
*/ | ||
typeref DummyAspect = union[Urn] | ||
typeref DummyAspect = union[DummyRecord] |
9 changes: 9 additions & 0 deletions
9
dao-api/src/main/pegasus/com/linkedin/metadata/dummy/DummyRecord.pdl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace com.linkedin.metadata.dummy | ||
|
||
/** | ||
* Not to be used | ||
*/ | ||
record DummyRecord { | ||
|
||
value: string | ||
} |
5 changes: 5 additions & 0 deletions
5
testing/test-models/src/main/pegasus/com/linkedin/testing/PizzaArrayAspect.pdl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace com.linkedin.testing | ||
|
||
typeref PizzaArrayAspect = union[ | ||
array[long] | ||
] |
5 changes: 5 additions & 0 deletions
5
testing/test-models/src/main/pegasus/com/linkedin/testing/PizzaEnumAspect.pdl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace com.linkedin.testing | ||
|
||
typeref PizzaEnumAspect = union[ | ||
PizzaSize | ||
] |
5 changes: 5 additions & 0 deletions
5
testing/test-models/src/main/pegasus/com/linkedin/testing/PizzaMapAspect.pdl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace com.linkedin.testing | ||
|
||
typeref PizzaMapAspect = union[ | ||
map[string, boolean] | ||
] |
5 changes: 5 additions & 0 deletions
5
testing/test-models/src/main/pegasus/com/linkedin/testing/PizzaStringAspect.pdl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace com.linkedin.testing | ||
|
||
typeref PizzaStringAspect = union[ | ||
string | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
validators/src/test/java/com/linkedin/metadata/validator/ValidationUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.linkedin.metadata.validator; | ||
|
||
import com.linkedin.data.schema.UnionDataSchema; | ||
import com.linkedin.testing.PizzaArrayAspect; | ||
import com.linkedin.testing.PizzaEnumAspect; | ||
import com.linkedin.testing.PizzaMapAspect; | ||
import com.linkedin.testing.PizzaStringAspect; | ||
import org.testng.annotations.Test; | ||
|
||
import static org.testng.Assert.*; | ||
|
||
|
||
public class ValidationUtilsTest { | ||
|
||
@Test | ||
public void testUnionWithEnums() { | ||
UnionDataSchema dataSchema = ValidationUtils.getUnionSchema(PizzaEnumAspect.class); | ||
assertFalse(ValidationUtils.isUnionWithOnlyRecordMembers(dataSchema)); | ||
} | ||
|
||
@Test | ||
public void testUnionWithMaps() { | ||
UnionDataSchema dataSchema = ValidationUtils.getUnionSchema(PizzaMapAspect.class); | ||
assertFalse(ValidationUtils.isUnionWithOnlyRecordMembers(dataSchema)); | ||
} | ||
|
||
@Test | ||
public void testUnionWithArrays() { | ||
UnionDataSchema dataSchema = ValidationUtils.getUnionSchema(PizzaArrayAspect.class); | ||
assertFalse(ValidationUtils.isUnionWithOnlyRecordMembers(dataSchema)); | ||
} | ||
|
||
@Test | ||
public void testUnionWithPrimitive() { | ||
UnionDataSchema dataSchema = ValidationUtils.getUnionSchema(PizzaStringAspect.class); | ||
assertFalse(ValidationUtils.isUnionWithOnlyRecordMembers(dataSchema)); | ||
} | ||
} |