-
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.
finos#1415 added extension methods to help add table to module for te…
…st usecases
- Loading branch information
Showing
4 changed files
with
114 additions
and
41 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
62 changes: 62 additions & 0 deletions
62
vuu/src/test/scala/org/finos/vuu/net/TestModuleBuilder.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,62 @@ | ||
package org.finos.vuu.net | ||
|
||
import org.finos.toolbox.lifecycle.LifecycleContainer | ||
import org.finos.toolbox.time.Clock | ||
import org.finos.vuu.api.{TableDef, ViewPortDef} | ||
import org.finos.vuu.core.module.{ModuleFactory, ModuleFactoryNode, TableDefContainer, ViewServerModule} | ||
import org.finos.vuu.provider.MockProvider | ||
|
||
|
||
object TestExtension { | ||
implicit class ModuleFactoryExtension(val moduleFactoryNode: ModuleFactoryNode) { | ||
|
||
def addTableForTest(tableDef: TableDef)(implicit clock: Clock, lifecycle: LifecycleContainer): ModuleFactoryNode = { | ||
moduleFactoryNode.addTable( | ||
tableDef, | ||
(table, _) => new MockProvider(table) | ||
) | ||
} | ||
|
||
def addTableForTest(tableDef: TableDef, viewPortDef: ViewPortDef)(implicit clock: Clock, lifecycle: LifecycleContainer): ModuleFactoryNode = { | ||
moduleFactoryNode.addTable( | ||
tableDef, | ||
(table, _) => new MockProvider(table), | ||
(_, _, _, _) => viewPortDef | ||
) | ||
} | ||
|
||
} | ||
} | ||
class TestModuleBuilder(moduleName:String)(implicit clock: Clock, lifecycle: LifecycleContainer, tableDefContainer: TableDefContainer){ | ||
|
||
|
||
private var moduleFactory = ModuleFactory.withNamespace(moduleName) | ||
def withTable(tableDef: TableDef, viewPortDef: ViewPortDef): TestModuleBuilder = { | ||
moduleFactory = moduleFactory.addTable( | ||
tableDef, | ||
(table, _) => new MockProvider(table), | ||
(_, _, _, _) => viewPortDef | ||
) | ||
this | ||
} | ||
|
||
|
||
def build(moduleName: String, tableDef: TableDef, viewPortDef: ViewPortDef)(implicit clock: Clock, lifecycle: LifecycleContainer, tableDefContainer: TableDefContainer): ViewServerModule = | ||
ModuleFactory.withNamespace(moduleName) | ||
.addTable( | ||
tableDef, | ||
(table, _) => new MockProvider(table), | ||
(_, _, _, _) => viewPortDef | ||
) | ||
.asModule() | ||
|
||
def build(moduleName: String, tableDef: TableDef)(implicit clock: Clock, lifecycle: LifecycleContainer, tableDefContainer: TableDefContainer): ViewServerModule = | ||
ModuleFactory.withNamespace(moduleName) | ||
.addTable( | ||
tableDef, | ||
(table, _) => new MockProvider(table) | ||
) | ||
.asModule() | ||
|
||
|
||
} |
18 changes: 0 additions & 18 deletions
18
vuu/src/test/scala/org/finos/vuu/net/TestModuleFactory.scala
This file was deleted.
Oops, something went wrong.
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