Skip to content

Commit

Permalink
OK-638: getKoulutus
Browse files Browse the repository at this point in the history
  • Loading branch information
pkalliok committed Feb 11, 2025
1 parent 56965e5 commit 08156e9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.asynchttpclient._

import fi.oph.kouta.logging.Logging
import fi.oph.kouta.external.util.KoutaJsonFormats
import fi.oph.kouta.external.domain.indexed.ToteutusIndexed
import fi.oph.kouta.external.domain.indexed.{KoulutusIndexed, ToteutusIndexed}
import java.util.concurrent.CompletableFuture

abstract class Query
Expand Down Expand Up @@ -63,6 +63,9 @@ trait ElasticClient extends Logging with KoutaJsonFormats {
}
}

def getKoulutus(oid: String): KoulutusIndexed =
(getJson(s"koulutus-kouta/_doc/$oid") \ "_source").extract[KoulutusIndexed]

def getToteutus(oid: String): ToteutusIndexed =
(getJson(s"toteutus-kouta/_doc/$oid") \ "_source").extract[ToteutusIndexed]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ class ElasticClientSpec extends ScalatraFlatSpec with ElasticFixture {
== "1.2.246.562.13.00000000000000000001")
}

"example koulutus" should "be loadable" in {
val kou = ElasticClient.getKoulutus("1.2.246.562.13.00000000000000000006")
assert(kou.koulutukset(0).koodiUri == "koulutus_371101#1")
assert(kou.tila.name == "julkaistu")
}

"published toteutukset" should "have both toteutukset" in {
val result = ElasticClient.listPublished(None)
assert(result.toArray.length == 2) // testidatan molemmat toteutukset ovat julkaistuja
Expand Down

0 comments on commit 08156e9

Please sign in to comment.