|
24 | 24 | import com.fasterxml.jackson.databind.JsonNode;
|
25 | 25 | import com.fasterxml.jackson.databind.ObjectMapper;
|
26 | 26 | import com.fasterxml.jackson.databind.node.ObjectNode;
|
| 27 | +import io.airbyte.api.model.generated.BuilderProjectForDefinitionRequestBody; |
| 28 | +import io.airbyte.api.model.generated.BuilderProjectForDefinitionResponse; |
27 | 29 | import io.airbyte.api.model.generated.ConnectorBuilderHttpRequest;
|
28 | 30 | import io.airbyte.api.model.generated.ConnectorBuilderHttpRequest.HttpMethodEnum;
|
29 | 31 | import io.airbyte.api.model.generated.ConnectorBuilderHttpResponse;
|
|
85 | 87 | import java.time.OffsetDateTime;
|
86 | 88 | import java.util.Collections;
|
87 | 89 | import java.util.List;
|
| 90 | +import java.util.Optional; |
88 | 91 | import java.util.UUID;
|
89 | 92 | import java.util.function.Supplier;
|
90 | 93 | import java.util.stream.Stream;
|
@@ -755,6 +758,31 @@ void testGetBaseImageForDeclarativeManifest() {
|
755 | 758 | assertEquals(A_BASE_IMAGE, responseBody.getBaseImage());
|
756 | 759 | }
|
757 | 760 |
|
| 761 | + @Test |
| 762 | + void testGetConnectorBuilderProjectIdBySourceDefinitionId() throws IOException { |
| 763 | + final UUID actorDefinitionId = UUID.randomUUID(); |
| 764 | + final UUID projectId = UUID.randomUUID(); |
| 765 | + final UUID workspaceId = UUID.randomUUID(); |
| 766 | + when(connectorBuilderService.getConnectorBuilderProjectIdForActorDefinitionId(actorDefinitionId)).thenReturn(Optional.of(projectId)); |
| 767 | + |
| 768 | + final BuilderProjectForDefinitionResponse response = connectorBuilderProjectsHandler.getConnectorBuilderProjectForDefinitionId( |
| 769 | + new BuilderProjectForDefinitionRequestBody().actorDefinitionId(actorDefinitionId).workspaceId(workspaceId)); |
| 770 | + |
| 771 | + assertEquals(projectId, response.getBuilderProjectId()); |
| 772 | + } |
| 773 | + |
| 774 | + @Test |
| 775 | + void testGetConnectorBuilderProjectIdBySourceDefinitionIdWhenNotFound() throws IOException { |
| 776 | + final UUID actorDefinitionId = UUID.randomUUID(); |
| 777 | + final UUID workspaceId = UUID.randomUUID(); |
| 778 | + when(connectorBuilderService.getConnectorBuilderProjectIdForActorDefinitionId(actorDefinitionId)).thenReturn(Optional.empty()); |
| 779 | + |
| 780 | + final BuilderProjectForDefinitionResponse response = connectorBuilderProjectsHandler.getConnectorBuilderProjectForDefinitionId( |
| 781 | + new BuilderProjectForDefinitionRequestBody().actorDefinitionId(actorDefinitionId).workspaceId(workspaceId)); |
| 782 | + |
| 783 | + assertNull(response.getBuilderProjectId()); |
| 784 | + } |
| 785 | + |
758 | 786 | private static ConnectorBuilderPublishRequestBody anyConnectorBuilderProjectRequest() {
|
759 | 787 | return new ConnectorBuilderPublishRequestBody().initialDeclarativeManifest(anyInitialManifest());
|
760 | 788 | }
|
|
0 commit comments