diff --git a/src/main/kotlin/org/akrck02/valhalla/core/dal/Main.kt b/src/main/kotlin/org/akrck02/valhalla/core/dal/Main.kt deleted file mode 100644 index 31cd57e..0000000 --- a/src/main/kotlin/org/akrck02/valhalla/core/dal/Main.kt +++ /dev/null @@ -1,33 +0,0 @@ -package org.akrck02.valhalla.core.dal - -import com.mongodb.kotlin.client.coroutine.MongoDatabase -import kotlinx.coroutines.launch -import kotlinx.coroutines.runBlocking -import org.akrck02.valhalla.core.dal.configuration.getCurrentDatabaseConfiguration -import org.akrck02.valhalla.core.dal.database.Databases -import org.akrck02.valhalla.core.dal.database.Mongo -import org.akrck02.valhalla.core.dal.service.user.registerUser -import org.akrck02.valhalla.core.sdk.model.exception.ServiceException -import org.akrck02.valhalla.core.sdk.model.user.User - -fun main() { - - runBlocking { - - val mongo = Mongo().also { it.connect(getCurrentDatabaseConfiguration()) } - val database: MongoDatabase? = mongo.client?.getDatabase(databaseName = Databases.Valhalla.id) - launch { - database ?: throw ServiceException(message = "Database not connected!") - registerUser( - database, - User( - id = null, - username = "akrck01", - email = "akrck02@gmail.com", - password = "#PasswordisHereLoL#?" - ) - ) - } - - } -} \ No newline at end of file diff --git a/src/main/kotlin/org/akrck02/valhalla/core/dal/database/Register.kt b/src/main/kotlin/org/akrck02/valhalla/core/dal/database/DatabaseConstants.kt similarity index 100% rename from src/main/kotlin/org/akrck02/valhalla/core/dal/database/Register.kt rename to src/main/kotlin/org/akrck02/valhalla/core/dal/database/DatabaseConstants.kt diff --git a/src/main/kotlin/org/akrck02/valhalla/core/dal/service/project/Project.kt b/src/main/kotlin/org/akrck02/valhalla/core/dal/service/project/ProjectDataAccess.kt similarity index 69% rename from src/main/kotlin/org/akrck02/valhalla/core/dal/service/project/Project.kt rename to src/main/kotlin/org/akrck02/valhalla/core/dal/service/project/ProjectDataAccess.kt index 0203321..1d6c7ec 100644 --- a/src/main/kotlin/org/akrck02/valhalla/core/dal/service/project/Project.kt +++ b/src/main/kotlin/org/akrck02/valhalla/core/dal/service/project/ProjectDataAccess.kt @@ -1,2 +1,3 @@ package org.akrck02.valhalla.core.dal.service.project +class UserDataAccessTest \ No newline at end of file diff --git a/src/main/kotlin/org/akrck02/valhalla/core/dal/service/user/user.kt b/src/main/kotlin/org/akrck02/valhalla/core/dal/service/user/UserDataAccess.kt similarity index 100% rename from src/main/kotlin/org/akrck02/valhalla/core/dal/service/user/user.kt rename to src/main/kotlin/org/akrck02/valhalla/core/dal/service/user/UserDataAccess.kt diff --git a/src/test/kotlin/org/akrck02/valhalla/core/dal/service/user/UserDataAccessTest.kt b/src/test/kotlin/org/akrck02/valhalla/core/dal/service/user/UserDataAccessTest.kt new file mode 100644 index 0000000..dc111b7 --- /dev/null +++ b/src/test/kotlin/org/akrck02/valhalla/core/dal/service/user/UserDataAccessTest.kt @@ -0,0 +1,45 @@ +package org.akrck02.valhalla.core.dal.service.user + +import com.mongodb.kotlin.client.coroutine.MongoDatabase +import kotlinx.coroutines.launch +import kotlinx.coroutines.runBlocking +import org.akrck02.valhalla.core.dal.configuration.getCurrentDatabaseConfiguration +import org.akrck02.valhalla.core.dal.database.Databases +import org.akrck02.valhalla.core.dal.database.Mongo +import org.akrck02.valhalla.core.sdk.model.exception.ServiceException +import org.akrck02.valhalla.core.sdk.model.user.User +import org.junit.jupiter.api.BeforeEach +import kotlin.test.Test + +class UserDataAccessTest { + + @BeforeEach + fun resetDatabase() { + runBlocking { + val mongo = Mongo().also { it.connect(getCurrentDatabaseConfiguration()) } + val database: MongoDatabase? = mongo.client?.getDatabase(databaseName = Databases.ValhallaTest.id) + database ?: throw ServiceException(message = "Cannot connect to database") + } + } + + @Test + fun userRegisterTest() { + runBlocking { + val mongo = Mongo().also { it.connect(getCurrentDatabaseConfiguration()) } + val database: MongoDatabase? = mongo.client?.getDatabase(databaseName = Databases.ValhallaTest.id) + launch { + database ?: throw ServiceException(message = "Database not connected!") + registerUser( + database, + User( + id = null, + username = "akrck01", + email = "akrck02@gmail.com", + password = "#PasswordisHereLoL#?" + ) + ) + } + + } + } +}