Skip to content

Commit

Permalink
convert test classes to kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
edgao committed Jun 3, 2024
1 parent f871777 commit 2af3bd1
Show file tree
Hide file tree
Showing 26 changed files with 1,809 additions and 1,633 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2023 Airbyte, Inc., all rights reserved.
*/
package io.airbyte.integrations.destination.redshift

import java.sql.Connection
import java.sql.SQLException

object RedshiftConnectionHandler {
/**
* For to close a connection. Aimed to be use in test only.
*
* @param connection The connection to close
*/
fun close(connection: Connection?) {
try {
connection!!.autoCommit = false
connection.commit()
connection.close()
} catch (e: SQLException) {
throw RuntimeException(e)
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2023 Airbyte, Inc., all rights reserved.
*/
package io.airbyte.integrations.destination.redshift

import com.fasterxml.jackson.databind.node.ObjectNode
import io.airbyte.commons.io.IOs.readFile
import io.airbyte.commons.json.Jsons.deserialize
import io.airbyte.protocol.models.v0.AirbyteConnectionStatus
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import java.nio.file.Path

class RedshiftConnectionTest {
private val config = deserialize(readFile(Path.of("secrets/config_staging.json")))
private val destination = RedshiftStagingS3Destination()
private var status: AirbyteConnectionStatus? = null

@Test
@Throws(Exception::class)
fun testCheckIncorrectPasswordFailure() {
(config as ObjectNode).put("password", "fake")
status = destination.check(config)
Assertions.assertEquals(AirbyteConnectionStatus.Status.FAILED, status!!.status)
Assertions.assertTrue(status!!.message.contains("State code: 28000;"))
}

@Test
@Throws(Exception::class)
fun testCheckIncorrectUsernameFailure() {
(config as ObjectNode).put("username", "")
status = destination.check(config)
Assertions.assertEquals(AirbyteConnectionStatus.Status.FAILED, status!!.status)
Assertions.assertTrue(status!!.message.contains("State code: 28000;"))
}

@Test
@Throws(Exception::class)
fun testCheckIncorrectHostFailure() {
(config as ObjectNode).put("host", "localhost2")
status = destination.check(config)
Assertions.assertEquals(AirbyteConnectionStatus.Status.FAILED, status!!.status)
Assertions.assertTrue(status!!.message.contains("State code: 08001;"))
}

@Test
@Throws(Exception::class)
fun testCheckIncorrectDataBaseFailure() {
(config as ObjectNode).put("database", "wrongdatabase")
status = destination.check(config)
Assertions.assertEquals(AirbyteConnectionStatus.Status.FAILED, status!!.status)
Assertions.assertTrue(status!!.message.contains("State code: 3D000;"))
}
}
Loading

0 comments on commit 2af3bd1

Please sign in to comment.