Commit cf917297 authored by Areum Kim's avatar Areum Kim
Browse files

[Issue, #36] resolve threads

parent 4dbdd330
Pipeline #77955 passed with stages
in 2 minutes and 44 seconds
......@@ -21,33 +21,69 @@ data class FAQData(
var unprocessed: MutableList<String>
)
{
var jsonDocxConfig: JSONDocxConfig ?= null
var jsonUrlConfig : JSONUrlConfig ?= null
constructor(): this(newId(), "docx", "name", setTimestamp(),
constructor(): this(
newId(),
"docx",
"name",
setTimestamp(),
mutableListOf("2021-06-13T11:45", "2021-06-13T11:46"),
"status", mutableListOf(Dialog()), mutableListOf("text 1", "text 2"))
"status",
mutableListOf(Dialog()),
mutableListOf("text 1", "text 2")
)
constructor(id: Id<FAQData>, type: String, name: String,
creationTimestamp: String, changeTimestamp: MutableList<String>
, status: String, dialogs: MutableList<Dialog>, unprocessed: MutableList<String>,
jsonDocxConfig: JSONDocxConfig): this(id, type, name, creationTimestamp, changeTimestamp, status, dialogs,
unprocessed)
constructor(
id: Id<FAQData>,
type: String,
name: String,
creationTimestamp: String,
changeTimestamp: MutableList<String>,
status: String,
dialogs: MutableList<Dialog>,
unprocessed: MutableList<String>,
jsonDocxConfig: JSONDocxConfig
):
this(
id,
type,
name,
creationTimestamp,
changeTimestamp,
status,
dialogs,
unprocessed
)
{
this.jsonDocxConfig = jsonDocxConfig
}
constructor(id: Id<FAQData>, type: String, name: String,
creationTimestamp: String, changeTimestamp: MutableList<String>,
status: String, dialogs: MutableList<Dialog>,
unprocessed: MutableList<String>, jsonUrlConfig : JSONUrlConfig): this(id, type, name, creationTimestamp,
changeTimestamp, status, dialogs,
unprocessed)
constructor(
id: Id<FAQData>,
type: String,
name: String,
creationTimestamp: String,
changeTimestamp: MutableList<String>,
status: String,
dialogs: MutableList<Dialog>,
unprocessed: MutableList<String>,
jsonUrlConfig : JSONUrlConfig
):
this(
id,
type,
name,
creationTimestamp,
changeTimestamp,
status,
dialogs,
unprocessed
)
{
this.jsonUrlConfig = jsonUrlConfig
}
}
data class Dialog (
......@@ -57,15 +93,36 @@ data class Dialog (
val answer: String,
val summaries: MutableList<Summary> )
{
constructor(): this("d1", "What time is it?", mutableListOf("time?", "what is the time?"), "12h00",
mutableListOf(Summary(200, "message", SummaryBody("strategy",0.0,"summary"))))
constructor(): this(
"d1",
"What time is it?",
mutableListOf(
"time?",
"what is the time?"
),
"12h00",
mutableListOf(
Summary(
200,
"message",
SummaryBody(
"strategy",
0.0,
"summary"
)
)
)
)
}
const val dataFormat = "yyyy-MM-dd'T'HH:mm'Z'"
// set current time
fun setTimestamp(): String {
val tz: TimeZone = TimeZone.getTimeZone("UTC")
val df: DateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'") // Quoted "Z" to indicate UTC, no timezone offset
val df: DateFormat = SimpleDateFormat(dataFormat) // Quoted "Z" to indicate UTC, no timezone offset
df.timeZone = tz
return df.format(Date())
}
\ No newline at end of file
}
......@@ -8,7 +8,7 @@ import org.bson.Document
import org.bson.types.ObjectId
import org.litote.kmongo.*
class MongoData {
class FAQDataRepository {
var col: MongoCollection<FAQData>
private val database: MongoDatabase
private val dbName = "chats"
......
......@@ -6,7 +6,15 @@ data class JSONDocxConfig(
val question:QuestionDocx
)
{
constructor(): this("none", "none", QuestionDocx("none", "none", Integer(0)))
constructor(): this(
"none",
"none",
QuestionDocx(
"none",
"none",
Integer(0)
)
)
}
data class QuestionDocx(
......
......@@ -24,8 +24,16 @@ data class JSONUrlConfig(
val answer:Answer
)
{
constructor(): this("none", "none",
Question("none", "none"), Answer("none", "none"))
constructor(): this(
"none",
"none",
Question(
"none",
"none"),
Answer(
"none",
"none")
)
}
data class Question(
......
package de.h_da.fbi.smebt.intentfinder.server.sources
/*
import junit.framework.Assert.assertEquals
import org.junit.jupiter.api.*
import org.junit.runner.RunWith
import org.mockito.junit.MockitoJUnitRunner
import org.mockito.Mockito.mock
import org.mockito.Mockito.`when`
@RunWith(MockitoJUnitRunner::class)
class MongoDataTest {
lateinit var faqData : FAQData
lateinit var mongoData : MongoData
@BeforeEach
fun setUp() {
faqData = FAQData()
mongoData = mock(MongoData::class.java)
mongoData.insertFaqDataDocxInMongo(faqData)
}
@AfterEach
fun tearDown(){
mongoData.deleteAllFaqData()
}
@Test
fun insertFaqDataDocxInMongo() {
`when`(mongoData.insertFaqDataDocxInMongo(faqData)).thenReturn(faqData.id)
assertEquals(faqData.id, mongoData.insertFaqDataDocxInMongo(faqData))
}
@Test
fun insertFaqDataUrlInMongo() {
`when`(mongoData.insertFaqDataUrlInMongo(faqData)).thenReturn(faqData.id)
assertEquals(faqData.id, mongoData.insertFaqDataUrlInMongo(faqData))
}
@Test
fun getFaqDataById() {
`when`(mongoData.getFaqDataById(faqData.id.toString())).thenReturn(faqData)
assertEquals(faqData, mongoData.getFaqDataById(faqData.id.toString()))
}
@Test
fun addTimestamp() {
`when`(mongoData.addTimestamp(faqData.id.toString())).thenReturn(true)
assertEquals(true, mongoData.addTimestamp(faqData.id.toString()))
}
@Test
fun updateFaqDataName() {
`when`(mongoData.updateFaqDataName(faqData.id.toString(),"NEW_name")).thenReturn(true)
assertEquals(true, mongoData.updateFaqDataName(faqData.id.toString(),"NEW_name"))
}
@Test
fun updateFaqDataType() {
`when`(mongoData.updateFaqDataType(faqData.id.toString(),"NEW_type")).thenReturn(true)
assertEquals(true, mongoData.updateFaqDataType(faqData.id.toString(),"NEW_type"))
}
@Test
fun updateFaqDataJsonDocxConfigType() {
`when`(mongoData.updateFaqDataJsonDocxConfigType(faqData.id.toString(),"NEW_docx_type")).thenReturn(true)
assertEquals(true, mongoData.updateFaqDataJsonDocxConfigType(faqData.id.toString(),"NEW_docx_type"))
}
@Test
fun updateFaqDataJsonDocxConfigName() {
`when`(mongoData.updateFaqDataJsonDocxConfigName(faqData.id.toString(),"NEW_docx_name")).thenReturn(true)
assertEquals(true, mongoData.updateFaqDataJsonDocxConfigName(faqData.id.toString(),"NEW_docx_name"))
}
@Test
fun updateFaqDataJsonDocxConfigQuestionStyle() {
`when`(mongoData.updateFaqDataJsonDocxConfigQuestionStyle(faqData.id.toString(),"NEW_docx_question_style")).thenReturn(true)
assertEquals(true, mongoData.updateFaqDataJsonDocxConfigQuestionStyle(faqData.id.toString(),"NEW_docx_question_style"))
}
@Test
fun updateFaqDataJsonDocxConfigQuestionFormat() {
`when`(mongoData.updateFaqDataJsonDocxConfigQuestionFormat(faqData.id.toString(),"NEW_docx_question_format")).thenReturn(true)
assertEquals(true, mongoData.updateFaqDataJsonDocxConfigQuestionFormat(faqData.id.toString(),"NEW_docx_question_format"))
}
@Test
fun updateFaqDataJsonDocxConfigQuestionSize() {
`when`(mongoData.updateFaqDataJsonDocxConfigQuestionSize(faqData.id.toString(),10)).thenReturn(true)
assertEquals(true, mongoData.updateFaqDataJsonDocxConfigQuestionSize(faqData.id.toString(),10))
}
@Test
fun updateFaqDataJsonUrlConfigType() {
`when`(mongoData.updateFaqDataJsonUrlConfigType(faqData.id.toString(),"NEW_url_type")).thenReturn(true)
assertEquals(true, mongoData.updateFaqDataJsonUrlConfigType(faqData.id.toString(),"NEW_url_type"))
}
@Test
fun updateFaqDataJsonUrlConfigName() {
`when`(mongoData.updateFaqDataJsonUrlConfigName(faqData.id.toString(),"NEW_url_name")).thenReturn(true)
assertEquals(true, mongoData.updateFaqDataJsonUrlConfigName(faqData.id.toString(),"NEW_url_name"))
}
@Test
fun updateFaqDataJsonUrlConfigQuestionType() {
`when`(mongoData.updateFaqDataJsonUrlConfigQuestionType(faqData.id.toString(),"NEW_url_question_type")).thenReturn(true)
assertEquals(true, mongoData.updateFaqDataJsonUrlConfigQuestionType(faqData.id.toString(),"NEW_url_question_type"))
}
@Test
fun updateFaqDataJsonUrlConfigQuestionCss() {
`when`(mongoData.updateFaqDataJsonUrlConfigQuestionCss(faqData.id.toString(),"NEW_url_question_css")).thenReturn(true)
assertEquals(true, mongoData.updateFaqDataJsonUrlConfigQuestionCss(faqData.id.toString(),"NEW_url_question_css"))
}
@Test
fun updateFaqDataJsonUrlConfigAnswerType() {
`when`(mongoData.updateFaqDataJsonUrlConfigAnswerType(faqData.id.toString(),"NEW_url_answer_type")).thenReturn(true)
assertEquals(true, mongoData.updateFaqDataJsonUrlConfigAnswerType(faqData.id.toString(),"NEW_url_answer_type"))
}
@Test
fun updateFaqDataJsonUrlConfigAnswerHref() {
`when`(mongoData.updateFaqDataJsonUrlConfigAnswerHref(faqData.id.toString(),"NEW_url_answer_href")).thenReturn(true)
assertEquals(true, mongoData.updateFaqDataJsonUrlConfigAnswerHref(faqData.id.toString(),"NEW_url_answer_href"))
}
@Test
fun updateFaqDataJsonUrlConfigAnswerCss() {
`when`(mongoData.updateFaqDataJsonUrlConfigAnswerCss(faqData.id.toString(),"NEW_url_answer_css")).thenReturn(true)
assertEquals(true, mongoData.updateFaqDataJsonUrlConfigAnswerCss(faqData.id.toString(),"NEW_url_answer_css"))
}
@Test
fun updateFaqDataStatus() {
`when`(mongoData.updateFaqDataStatus(faqData.id.toString(),"NEW_status")).thenReturn(true)
assertEquals(true, mongoData.updateFaqDataStatus(faqData.id.toString(),"NEW_status"))
}
@Test
fun updateFaqDataDialogQuestion() {
`when`(mongoData.updateFaqDataDialogQuestion(faqData.id.toString(),"NEW_dialog_question", "d1")).thenReturn(true)
assertEquals(true, mongoData.updateFaqDataDialogQuestion(faqData.id.toString(),"NEW_dialog_question", "d1"))
}
@Test
fun updateFaqDataDialogAnswer() {
`when`(mongoData.updateFaqDataDialogAnswer(faqData.id.toString(),"NEW_dialog_answer", "d1")).thenReturn(true)
assertEquals(true, mongoData.updateFaqDataDialogAnswer(faqData.id.toString(),"NEW_dialog_answer", "d1"))
}
@Test
fun updateFaqDataDialogAlternativeQuestion() {
`when`(mongoData.updateFaqDataDialogAlternativeQuestion(faqData.id.toString(),0, "NEW_dialog_alternate_question","d1" )).thenReturn(true)
assertEquals(true, mongoData.updateFaqDataDialogAlternativeQuestion(faqData.id.toString(),0, "NEW_dialog_alternate_question","d1" ))
}
@Test
fun updateFaqDataDialogSummaryStrategy() {
`when`(mongoData.updateFaqDataDialogSummaryStrategy(faqData.id.toString(),0, "NEW_dialog_summary_strategy","d1" )).thenReturn(true)
assertEquals(true, mongoData.updateFaqDataDialogSummaryStrategy(faqData.id.toString(),0, "NEW_dialog_summary_strategy","d1" ))
}
@Test
fun updateFaqDataDialogSummaryQuality() {
`when`(mongoData.updateFaqDataDialogSummaryQuality(faqData.id.toString(),0, 10.0,"d1" )).thenReturn(true)
assertEquals(true, mongoData.updateFaqDataDialogSummaryQuality(faqData.id.toString(),0, 10.0,"d1" ))
}
@Test
fun updateFaqDataDialogSummaryResult() {
`when`(mongoData.updateFaqDataDialogSummaryResult(faqData.id.toString(),0,"NEW_dialog_summary_result","d1")).thenReturn(true)
assertEquals(true, mongoData.updateFaqDataDialogSummaryResult(faqData.id.toString(),0,"NEW_dialog_summary_result","d1"))
}
@Test
fun updateFaqDataUnprocessed() {
`when`(mongoData.updateFaqUnprocessed(faqData.id.toString(),"MEW_unprocessed")).thenReturn(true)
assertEquals(true, mongoData.updateFaqUnprocessed(faqData.id.toString(),"MEW_unprocessed"))
}
}*/
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment