@@ -54,6 +54,8 @@ class SiloClientTest(
54
54
55
55
private var counter = 0
56
56
57
+ private val columnName = " test_column"
58
+
57
59
@BeforeEach
58
60
fun setup () {
59
61
mockServer = ClientAndServer .startClientAndServer(MOCK_SERVER_PORT )
@@ -439,31 +441,19 @@ class SiloClientTest(
439
441
440
442
@Test
441
443
fun `get lineage definition` () {
442
- val columnName = " test_column"
443
- MockServerClient (" localhost" , MOCK_SERVER_PORT )
444
- .`when `(
445
- request()
446
- .withMethod(" GET" )
447
- .withPath(" /lineageDefinition/$columnName " )
448
- .withHeader(" X-Request-Id" , REQUEST_ID_VALUE ),
449
- )
450
- .respond(
451
- response()
452
- .withStatusCode(200 )
453
- .withBody(
454
- """
455
- A: {}
456
- A.1:
457
- parents:
458
- - A
459
- B:
460
- aliases:
461
- - A.1.1
462
- parents:
463
- - A.1
464
- """ .trimIndent(),
465
- ),
466
- )
444
+ expectLineageDefinitionRequestAndRespondWith(
445
+ """
446
+ A: {}
447
+ A.1:
448
+ parents:
449
+ - A
450
+ B:
451
+ aliases:
452
+ - A.1.1
453
+ parents:
454
+ - A.1
455
+ """ .trimIndent(),
456
+ )
467
457
468
458
val actual = underTest.getLineageDefinition(columnName)
469
459
@@ -479,9 +469,24 @@ class SiloClientTest(
479
469
)
480
470
}
481
471
472
+ @Test
473
+ fun `GIVEN silo returns empty lineage definition file THEN returns empty object` () {
474
+ expectLineageDefinitionRequestAndRespondWith(" " )
475
+
476
+ val actual = underTest.getLineageDefinition(columnName)
477
+
478
+ assertThat(actual, equalTo(emptyMap()))
479
+ }
480
+
482
481
@Test
483
482
fun `GIVEN silo returns invalid lineage definition file THEN returns appropriate error` () {
484
- val columnName = " test_column"
483
+ expectLineageDefinitionRequestAndRespondWith(" not an object" )
484
+
485
+ val exception = assertThrows<RuntimeException > { underTest.getLineageDefinition(columnName) }
486
+ assertThat(exception.message, containsString(" Failed to parse lineage definition from SILO: " ))
487
+ }
488
+
489
+ private fun expectLineageDefinitionRequestAndRespondWith (lineageDefinition : String ) {
485
490
MockServerClient (" localhost" , MOCK_SERVER_PORT )
486
491
.`when `(
487
492
request()
@@ -492,11 +497,8 @@ class SiloClientTest(
492
497
.respond(
493
498
response()
494
499
.withStatusCode(200 )
495
- .withBody(" " ),
500
+ .withBody(lineageDefinition ),
496
501
)
497
-
498
- val exception = assertThrows<RuntimeException > { underTest.getLineageDefinition(columnName) }
499
- assertThat(exception.message, containsString(" Failed to parse lineage definition from SILO: " ))
500
502
}
501
503
502
504
companion object {
0 commit comments