1
1
package com .linkedin .metadata .models .registry ;
2
2
3
+ import com .linkedin .metadata .models .DataSchemaFactory ;
3
4
import com .linkedin .metadata .models .EntitySpec ;
4
5
import com .linkedin .metadata .models .EventSpec ;
6
+ import java .nio .file .Paths ;
5
7
import java .util .Map ;
6
- import org .apache .maven .artifact .versioning .ComparableVersion ;
7
8
import org .testng .annotations .Test ;
8
9
9
10
import static org .testng .Assert .*;
@@ -14,7 +15,11 @@ public class PatchEntityRegistryTest {
14
15
@ Test
15
16
public void testEntityRegistryLoad () throws Exception , EntityRegistryException {
16
17
PatchEntityRegistry patchEntityRegistry = new PatchEntityRegistry (
17
- TestConstants .BASE_DIRECTORY + "/" + TestConstants .TEST_REGISTRY + "/" + TestConstants .TEST_VERSION .toString (),
18
+ TestConstants .BASE_DIRECTORY
19
+ + "/"
20
+ + TestConstants .TEST_REGISTRY
21
+ + "/"
22
+ + TestConstants .TEST_VERSION .toString (),
18
23
TestConstants .TEST_REGISTRY , TestConstants .TEST_VERSION );
19
24
20
25
Map <String , EntitySpec > entitySpecs = patchEntityRegistry .getEntitySpecs ();
@@ -34,14 +39,28 @@ public void testEntityRegistryLoad() throws Exception, EntityRegistryException {
34
39
}
35
40
36
41
/**
37
- * Validate that patch entity registries cannot have key aspects
42
+ * Validate that patch entity registries can have key aspects
38
43
* @throws Exception
39
44
* @throws EntityRegistryException
40
45
*/
41
46
@ Test
42
- public void testEntityRegistryWithKeyLoad () {
43
- assertThrows (EntityRegistryException .class ,
44
- () -> new PatchEntityRegistry ("src/test_plugins/mycompany-full-model/0.0.1" , "mycompany-full-model" ,
45
- new ComparableVersion ("0.0.1" )));
47
+ public void testEntityRegistryWithKeyLoad () throws Exception , EntityRegistryException {
48
+ DataSchemaFactory dataSchemaFactory = DataSchemaFactory .withCustomClasspath (
49
+ Paths .get (TestConstants .BASE_DIRECTORY
50
+ + "/"
51
+ + TestConstants .TEST_REGISTRY
52
+ + "/"
53
+ + TestConstants .TEST_VERSION .toString ()));
54
+
55
+ PatchEntityRegistry patchEntityRegistry = new PatchEntityRegistry (
56
+ dataSchemaFactory , Paths .get ("src/test_plugins/mycompany-full-model/0.0.1/entity-registry.yaml" ),
57
+ TestConstants .TEST_REGISTRY , TestConstants .TEST_VERSION );
58
+
59
+ Map <String , EntitySpec > entitySpecs = patchEntityRegistry .getEntitySpecs ();
60
+ assertEquals (entitySpecs .values ().size (), 1 );
61
+ EntitySpec newThingSpec = patchEntityRegistry .getEntitySpec ("newThing" );
62
+ assertNotNull (newThingSpec );
63
+ assertNotNull (newThingSpec .getKeyAspectSpec ());
64
+ assertNotNull (newThingSpec .getAspectSpec (TestConstants .TEST_ASPECT_NAME ));
46
65
}
47
66
}
0 commit comments