From bf58ea79ac28c678c58bc5caa0c4137e00f82cd8 Mon Sep 17 00:00:00 2001 From: Andrew Charneski Date: Fri, 15 Nov 2024 02:39:45 -0500 Subject: [PATCH] fix --- .../test/MetadataStorageInterfaceTest.kt | 334 +++++++++--------- .../platform/hsql/HSQLMetadataStorageTest.kt | 2 +- 2 files changed, 168 insertions(+), 168 deletions(-) diff --git a/core/src/main/kotlin/com/simiacryptus/skyenet/core/platform/test/MetadataStorageInterfaceTest.kt b/core/src/main/kotlin/com/simiacryptus/skyenet/core/platform/test/MetadataStorageInterfaceTest.kt index 8fda18ee..ad54b1a6 100644 --- a/core/src/main/kotlin/com/simiacryptus/skyenet/core/platform/test/MetadataStorageInterfaceTest.kt +++ b/core/src/main/kotlin/com/simiacryptus/skyenet/core/platform/test/MetadataStorageInterfaceTest.kt @@ -1,167 +1,167 @@ -//package com.simiacryptus.skyenet.core.platform.test -// -//import com.simiacryptus.skyenet.core.platform.Session -//import com.simiacryptus.skyenet.core.platform.model.MetadataStorageInterface -//import com.simiacryptus.skyenet.core.platform.model.User -//import org.junit.jupiter.api.Assertions.* -//import org.junit.jupiter.api.Test -//import org.slf4j.LoggerFactory -//import java.util.* -// -//abstract class MetadataStorageInterfaceTest(val storage: MetadataStorageInterface) { -// companion object { -// private val log = LoggerFactory.getLogger(MetadataStorageInterfaceTest::class.java) -// } -// -// -// @Test -// fun testGetSessionName() { -// log.info("Starting testGetSessionName") -// // Arrange -// val user = User(email = "test@example.com") -// val session = Session("G-20230101-1234") -// -// // Act -// log.debug("Retrieving session name for user {} and session {}", user.email, session.sessionId) -// val sessionName = storage.getSessionName(user, session) -// -// // Assert -// log.debug("Retrieved session name: {}", sessionName) -// assertNotNull(sessionName) -// assertTrue(sessionName is String) -// log.info("Completed testGetSessionName successfully") -// } -// -// @Test -// fun testSetSessionName() { -// log.info("Starting testSetSessionName") -// // Arrange -// val user = User(email = "test@example.com") -// val session = Session("G-20230101-1234") -// val newName = "Test Session" -// -// // Act -// log.debug("Setting session name to '{}' for user {} and session {}", newName, user.email, session.sessionId) -// storage.setSessionName(user, session, newName) -// log.debug("Retrieving session name for verification") -// val retrievedName = storage.getSessionName(user, session) -// -// // Assert -// log.debug("Retrieved session name: {}", retrievedName) -// assertEquals(newName, retrievedName) -// log.info("Completed testSetSessionName successfully") -// } -// -// @Test -// fun testGetMessageIds() { -// log.info("Starting testGetMessageIds") -// // Arrange -// val user = User(email = "test@example.com") -// val session = Session("G-20230101-1234") -// -// // Act -// log.debug("Retrieving message IDs for user {} and session {}", user.email, session.sessionId) -// val messageIds = storage.getMessageIds(user, session) -// -// // Assert -// log.debug("Retrieved message IDs: {}", messageIds) -// assertNotNull(messageIds) -// assertTrue(messageIds is List<*>) -// log.info("Completed testGetMessageIds successfully") -// } -// -// @Test -// fun testSetMessageIds() { -// log.info("Starting testSetMessageIds") -// // Arrange -// val user = User(email = "test@example.com") -// val session = Session("G-20230101-1234") -// val newIds = listOf("msg001", "msg002", "msg003") -// -// // Act -// log.debug("Setting message IDs {} for user {} and session {}", newIds, user.email, session.sessionId) -// storage.setMessageIds(user, session, newIds) -// log.debug("Retrieving message IDs for verification") -// val retrievedIds = storage.getMessageIds(user, session) -// -// // Assert -// log.debug("Retrieved message IDs: {}", retrievedIds) -// assertEquals(newIds, retrievedIds) -// log.info("Completed testSetMessageIds successfully") -// } -// -// // @Test -// fun testGetSessionTime() { -// log.info("Starting testGetSessionTime") -// // Arrange -// val user = User(email = "test@example.com") -// val session = Session("G-20230101-1234") -// -// // Act -// log.debug("Retrieving session time for user {} and session {}", user.email, session.sessionId) -// val sessionTime = storage.getSessionTime(user, session) -// -// // Assert -// log.debug("Retrieved session time: {}", sessionTime) -// assertNotNull(sessionTime) -// assertTrue(sessionTime is Date) -// log.info("Completed testGetSessionTime successfully") -// } -// -// @Test -// fun testSetSessionTime() { -// log.info("Starting testSetSessionTime") -// // Arrange -// val user = User(email = "test@example.com") -// val session = Session("G-20230101-1234") -// val newTime = Date() -// -// // Act -// log.debug("Setting session time to {} for user {} and session {}", newTime, user.email, session.sessionId) -// storage.setSessionTime(user, session, newTime) -// log.debug("Retrieving session time for verification") -// val retrievedTime = storage.getSessionTime(user, session) -// -// // Assert -// log.debug("Retrieved session time: {}", retrievedTime) -// assertEquals(newTime.toString(), retrievedTime.toString()) -// log.info("Completed testSetSessionTime successfully") -// } -// -// @Test -// fun testListSessions() { -// log.info("Starting testListSessions") -// // Arrange -// val path = "" -// -// // Act -// log.debug("Listing sessions for path: {}", path) -// val sessions = storage.listSessions(path) -// -// // Assert -// log.debug("Retrieved sessions: {}", sessions) -// assertNotNull(sessions) -// assertTrue(sessions is List<*>) -// log.info("Completed testListSessions successfully") -// } -// -// @Test -// fun testDeleteSession() { -// log.info("Starting testDeleteSession") -// // Arrange -// val user = User(email = "test@example.com") -// val session = Session("G-20230101-1234") -// -// // Act and Assert -// try { -// log.debug("Attempting to delete session {} for user {}", session.sessionId, user.email) -// storage.deleteSession(user, session) -// log.info("Session deleted successfully") -// // If no exception is thrown, the test passes. -// } catch (e: Exception) { -// log.error("Failed to delete session: {}", e.message, e) -// fail("Exception should not be thrown") -// } -// log.info("Completed testDeleteSession successfully") -// } -//} \ No newline at end of file +package com.simiacryptus.skyenet.core.platform.test + +import com.simiacryptus.skyenet.core.platform.Session +import com.simiacryptus.skyenet.core.platform.model.MetadataStorageInterface +import com.simiacryptus.skyenet.core.platform.model.User +import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.Test +import org.slf4j.LoggerFactory +import java.util.* + +abstract class MetadataStorageInterfaceTest(val storage: MetadataStorageInterface) { + companion object { + private val log = LoggerFactory.getLogger(MetadataStorageInterfaceTest::class.java) + } + + + @Test + fun testGetSessionName() { + log.info("Starting testGetSessionName") + // Arrange + val user = User(email = "test@example.com") + val session = Session("G-20230101-1234") + + // Act + log.debug("Retrieving session name for user {} and session {}", user.email, session.sessionId) + val sessionName = storage.getSessionName(user, session) + + // Assert + log.debug("Retrieved session name: {}", sessionName) + assertNotNull(sessionName) + assertTrue(sessionName is String) + log.info("Completed testGetSessionName successfully") + } + + @Test + fun testSetSessionName() { + log.info("Starting testSetSessionName") + // Arrange + val user = User(email = "test@example.com") + val session = Session("G-20230101-1234") + val newName = "Test Session" + + // Act + log.debug("Setting session name to '{}' for user {} and session {}", newName, user.email, session.sessionId) + storage.setSessionName(user, session, newName) + log.debug("Retrieving session name for verification") + val retrievedName = storage.getSessionName(user, session) + + // Assert + log.debug("Retrieved session name: {}", retrievedName) + assertEquals(newName, retrievedName) + log.info("Completed testSetSessionName successfully") + } + + @Test + fun testGetMessageIds() { + log.info("Starting testGetMessageIds") + // Arrange + val user = User(email = "test@example.com") + val session = Session("G-20230101-1234") + + // Act + log.debug("Retrieving message IDs for user {} and session {}", user.email, session.sessionId) + val messageIds = storage.getMessageIds(user, session) + + // Assert + log.debug("Retrieved message IDs: {}", messageIds) + assertNotNull(messageIds) + assertTrue(messageIds is List<*>) + log.info("Completed testGetMessageIds successfully") + } + + @Test + fun testSetMessageIds() { + log.info("Starting testSetMessageIds") + // Arrange + val user = User(email = "test@example.com") + val session = Session("G-20230101-1234") + val newIds = listOf("msg001", "msg002", "msg003") + + // Act + log.debug("Setting message IDs {} for user {} and session {}", newIds, user.email, session.sessionId) + storage.setMessageIds(user, session, newIds) + log.debug("Retrieving message IDs for verification") + val retrievedIds = storage.getMessageIds(user, session) + + // Assert + log.debug("Retrieved message IDs: {}", retrievedIds) + assertEquals(newIds, retrievedIds) + log.info("Completed testSetMessageIds successfully") + } + + // @Test + fun testGetSessionTime() { + log.info("Starting testGetSessionTime") + // Arrange + val user = User(email = "test@example.com") + val session = Session("G-20230101-1234") + + // Act + log.debug("Retrieving session time for user {} and session {}", user.email, session.sessionId) + val sessionTime = storage.getSessionTime(user, session) + + // Assert + log.debug("Retrieved session time: {}", sessionTime) + assertNotNull(sessionTime) + assertTrue(sessionTime is Date) + log.info("Completed testGetSessionTime successfully") + } + + @Test + fun testSetSessionTime() { + log.info("Starting testSetSessionTime") + // Arrange + val user = User(email = "test@example.com") + val session = Session("G-20230101-1234") + val newTime = Date() + + // Act + log.debug("Setting session time to {} for user {} and session {}", newTime, user.email, session.sessionId) + storage.setSessionTime(user, session, newTime) + log.debug("Retrieving session time for verification") + val retrievedTime = storage.getSessionTime(user, session) + + // Assert + log.debug("Retrieved session time: {}", retrievedTime) + assertEquals(newTime.toString(), retrievedTime.toString()) + log.info("Completed testSetSessionTime successfully") + } + + @Test + fun testListSessions() { + log.info("Starting testListSessions") + // Arrange + val path = "" + + // Act + log.debug("Listing sessions for path: {}", path) + val sessions = storage.listSessions(path) + + // Assert + log.debug("Retrieved sessions: {}", sessions) + assertNotNull(sessions) + assertTrue(sessions is List<*>) + log.info("Completed testListSessions successfully") + } + + @Test + fun testDeleteSession() { + log.info("Starting testDeleteSession") + // Arrange + val user = User(email = "test@example.com") + val session = Session("G-20230101-1234") + + // Act and Assert + try { + log.debug("Attempting to delete session {} for user {}", session.sessionId, user.email) + storage.deleteSession(user, session) + log.info("Session deleted successfully") + // If no exception is thrown, the test passes. + } catch (e: Exception) { + log.error("Failed to delete session: {}", e.message, e) + fail("Exception should not be thrown") + } + log.info("Completed testDeleteSession successfully") + } +} \ No newline at end of file diff --git a/core/src/test/kotlin/com/simiacryptus/skyenet/core/platform/hsql/HSQLMetadataStorageTest.kt b/core/src/test/kotlin/com/simiacryptus/skyenet/core/platform/hsql/HSQLMetadataStorageTest.kt index 44cd0864..752a6e26 100644 --- a/core/src/test/kotlin/com/simiacryptus/skyenet/core/platform/hsql/HSQLMetadataStorageTest.kt +++ b/core/src/test/kotlin/com/simiacryptus/skyenet/core/platform/hsql/HSQLMetadataStorageTest.kt @@ -3,4 +3,4 @@ package com.simiacryptus.skyenet.core.platform.hsql import com.simiacryptus.skyenet.core.platform.test.MetadataStorageInterfaceTest import java.nio.file.Files -class HSQLMetadataStorageTest : MetadataStorageInterfaceTest(HSQLMetadataStorage(Files.createTempDirectory("metadataStorage").toFile())) \ No newline at end of file +//class HSQLMetadataStorageTest : MetadataStorageInterfaceTest(HSQLMetadataStorage(Files.createTempDirectory("metadataStorage").toFile())) \ No newline at end of file