-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
264f510
commit 27fac52
Showing
10 changed files
with
353 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
version = "3.5.3" | ||
runner.dialect = scala212 | ||
|
||
maxColumn = 120 | ||
|
||
align.preset = some | ||
align.multiline = false | ||
|
||
align.tokens = [ | ||
{ | ||
code = "<-" | ||
}, | ||
{ | ||
code = "=>" | ||
owners = [{ | ||
regex = "Case" | ||
}] | ||
} | ||
] | ||
|
||
indent.main = 2 | ||
indent.defnSite = 2 | ||
|
||
lineEndings = unix | ||
|
||
docstrings.blankFirstLine = yes | ||
docstrings.style = AsteriskSpace | ||
docstrings.wrap = no | ||
docstrings.removeEmpty = true | ||
|
||
align.openParenDefnSite = false | ||
align.openParenCallSite = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 69 additions & 63 deletions
132
core/src/test/scala/za/co/absa/fadb/DBFunctionSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,69 @@ | ||
///* | ||
// * Copyright 2022 ABSA Group Limited | ||
// * | ||
// * Licensed under the Apache License, Version 2.0 (the "License"); | ||
// * you may not use this file except in compliance with the License. | ||
// * You may obtain a copy of the License at | ||
// * | ||
// * http://www.apache.org/licenses/LICENSE-2.0 | ||
// * | ||
// * Unless required by applicable law or agreed to in writing, software | ||
// * distributed under the License is distributed on an "AS IS" BASIS, | ||
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// * See the License for the specific language governing permissions and | ||
// * limitations under the License. | ||
// */ | ||
// | ||
//package za.co.absa.fadb | ||
// | ||
//import org.scalatest.funsuite.AnyFunSuite | ||
// | ||
//import scala.concurrent.{ExecutionContext, Future} | ||
//import za.co.absa.fadb.naming.implementations.SnakeCaseNaming.Implicits.namingConvention | ||
// | ||
//class DBFunctionSuite extends AnyFunSuite { | ||
// | ||
// private def neverHappens: Nothing = { | ||
// throw new Exception("Should never get here") | ||
// } | ||
// | ||
// private implicit object EngineThrow extends DBEngine { | ||
// override def run[R](query: QueryType[R]): Future[Seq[R]] = neverHappens | ||
// | ||
// override implicit val executor: ExecutionContext = ExecutionContext.Implicits.global | ||
// } | ||
// | ||
// private object FooNamed extends DBSchema | ||
// private object FooNameless extends DBSchema("") | ||
// | ||
// test("Function name check"){ | ||
// case class MyFunction(override val schema: DBSchema) extends DBFunction[Unit, Unit, DBEngine](schema) { | ||
// override protected def query(values: Unit): dBEngine.QueryType[Unit] = neverHappens | ||
// } | ||
// | ||
// val fnc1 = MyFunction(FooNamed) | ||
// val fnc2 = MyFunction(FooNameless) | ||
// | ||
// assert(fnc1.functionName == "foo_named.my_function") | ||
// assert(fnc2.functionName == "my_function") | ||
// } | ||
// | ||
// test("Function name override check"){ | ||
// case class MyFunction(override val schema: DBSchema) extends DBFunction[Unit, Unit, DBEngine](schema, "bar") { | ||
// override protected def query(values: Unit): dBEngine.QueryType[Unit] = neverHappens | ||
// } | ||
// | ||
// val fnc1 = MyFunction(FooNamed) | ||
// val fnc2 = MyFunction(FooNameless) | ||
// | ||
// assert(fnc1.functionName == "foo_named.bar") | ||
// assert(fnc2.functionName == "bar") | ||
// } | ||
// | ||
//} | ||
/* | ||
* Copyright 2022 ABSA Group Limited | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package za.co.absa.fadb | ||
|
||
import cats.implicits._ | ||
import org.scalatest.funsuite.AnyFunSuite | ||
import za.co.absa.fadb.DBFunction.DBSingleResultFunction | ||
import za.co.absa.fadb.naming.implementations.SnakeCaseNaming.Implicits.namingConvention | ||
|
||
import scala.concurrent.ExecutionContext.Implicits.global | ||
import scala.concurrent.Future | ||
|
||
class DBFunctionSuite extends AnyFunSuite { | ||
|
||
private def neverHappens: Nothing = { | ||
throw new Exception("Should never get here") | ||
} | ||
|
||
class EngineThrow extends DBEngine[Future] { | ||
override def run[R](query: QueryType[R]): Future[Seq[R]] = neverHappens | ||
} | ||
|
||
private object FooNamed extends DBSchema | ||
private object FooNameless extends DBSchema("") | ||
|
||
test("Function name check"){ | ||
|
||
class MyFunction(functionNameOverride: Option[String] = None)(implicit override val schema: DBSchema, val dbEngine: EngineThrow) | ||
extends DBSingleResultFunction[Unit, Unit, EngineThrow, Future](None) { | ||
|
||
override protected def query(values: Unit): dBEngine.QueryType[Unit] = neverHappens | ||
} | ||
|
||
val fnc1 = new MyFunction()(FooNamed, new EngineThrow) | ||
val fnc2 = new MyFunction()(FooNameless, new EngineThrow) | ||
|
||
assert(fnc1.functionName == "foo_named.my_function") | ||
assert(fnc2.functionName == "my_function") | ||
} | ||
|
||
test("Function name override check"){ | ||
class MyFunction(implicit override val schema: DBSchema, val dbEngine: EngineThrow) | ||
extends DBSingleResultFunction[Unit, Unit, EngineThrow, Future](Some("bar")) { | ||
|
||
override protected def query(values: Unit): dBEngine.QueryType[Unit] = neverHappens | ||
} | ||
|
||
val fnc1 = new MyFunction()(FooNamed, new EngineThrow) | ||
val fnc2 = new MyFunction()(FooNameless, new EngineThrow) | ||
|
||
assert(fnc1.functionName == "foo_named.bar") | ||
assert(fnc2.functionName == "bar") | ||
} | ||
|
||
} |
Oops, something went wrong.