forked from finos/vuu
-
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.
Merge pull request finos#1357 from finos/revert-1354-approvedpush_202…
…40520 Revert "finos#1318 improve ExternalEntitySchema api and add a `toMap` method"
- Loading branch information
Showing
6 changed files
with
32 additions
and
50 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
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
8 changes: 8 additions & 0 deletions
8
...e-ignite/src/main/scala/org/finos/vuu/example/ignite/utils/getListToObjectConverter.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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.finos.vuu.example.ignite.utils | ||
|
||
object getListToObjectConverter { | ||
def apply[ReturnType](obj: Object): List[_] => ReturnType = { | ||
val converter = obj.getClass.getMethods.find(x => x.getName == "apply" && x.isBridge).get | ||
values => converter.invoke(obj, values.map(_.asInstanceOf[AnyRef]): _*).asInstanceOf[ReturnType] | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...ite/src/test/scala/org/finos/vuu/example/ignite/schema/getListToObjectConverterTest.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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.finos.vuu.example.ignite.schema | ||
|
||
import org.finos.vuu.example.ignite.utils.getListToObjectConverter | ||
import org.scalatest.featurespec.AnyFeatureSpec | ||
import org.scalatest.matchers.should.Matchers | ||
|
||
class getListToObjectConverterTest extends AnyFeatureSpec with Matchers { | ||
|
||
Feature("getListToObjectConverterTest") { | ||
Scenario("Can build Dto from a list of values") { | ||
val dto = getListToObjectConverter[TestDto](TestDto)(List("TestObject", 25.5)) | ||
|
||
dto shouldEqual TestDto(name = "TestObject", value = 25.5) | ||
} | ||
} | ||
|
||
private case class TestDto(name: String, value: Double) | ||
} |
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