@@ -16,7 +16,7 @@ import pl.touk.nussknacker.engine.management.FlinkStreamingPropertiesConfig
16
16
import pl .touk .nussknacker .engine .util .Implicits .RichScalaMap
17
17
import pl .touk .nussknacker .restmodel .scenariodetails .ScenarioParameters
18
18
import pl .touk .nussknacker .security .Permission
19
- import pl .touk .nussknacker .test .config .WithSimplifiedDesignerConfig .{ TestCategory , TestProcessingType }
19
+ import pl .touk .nussknacker .test .config .WithSimplifiedDesignerConfig .TestCategory
20
20
import pl .touk .nussknacker .test .config .WithSimplifiedDesignerConfig .TestProcessingType .Streaming
21
21
import pl .touk .nussknacker .test .mock .{StubFragmentRepository , TestAdditionalUIConfigProvider }
22
22
import pl .touk .nussknacker .ui .api .{RouteWithoutUser , RouteWithUser }
@@ -65,57 +65,73 @@ object TestFactory {
65
65
66
66
val possibleValues : List [FixedExpressionValue ] = List (FixedExpressionValue (" a" , " a" ))
67
67
68
- val processValidator : UIProcessValidator = ProcessTestData .testProcessValidator(fragmentResolver = sampleResolver)
68
+ def processValidator (processingTypes : List [String ] = List (Streaming .stringify)): UIProcessValidator =
69
+ ProcessTestData .testProcessValidator(fragmentResolver = sampleResolver(processingTypes))
69
70
70
- val flinkProcessValidator : UIProcessValidator = ProcessTestData .testProcessValidator(
71
- fragmentResolver = sampleResolver,
72
- scenarioProperties = FlinkStreamingPropertiesConfig .properties
73
- )
71
+ def flinkProcessValidator (processingTypes : List [String ] = List (Streaming .stringify)): UIProcessValidator =
72
+ ProcessTestData .testProcessValidator(
73
+ fragmentResolver = sampleResolver(processingTypes),
74
+ scenarioProperties = FlinkStreamingPropertiesConfig .properties
75
+ )
74
76
75
- val processValidatorByProcessingType : ProcessingTypeDataProvider [UIProcessValidator , _] =
76
- mapProcessingTypeDataProvider(Streaming .stringify -> flinkProcessValidator)
77
+ def processValidatorByProcessingType (
78
+ processingTypes : List [String ] = List (Streaming .stringify)
79
+ ): ProcessingTypeDataProvider [UIProcessValidator , _] = {
80
+ val validator = flinkProcessValidator(processingTypes)
81
+ mapProcessingTypeDataProvider(processingTypes.map(pt => (pt, validator)): _* )
82
+ }
77
83
78
- val processResolver = new UIProcessResolver (
79
- processValidator,
84
+ def processResolver ( processingTypes : List [ String ] = List ( Streaming .stringify)) = new UIProcessResolver (
85
+ processValidator(processingTypes) ,
80
86
ProcessDictSubstitutor (new SimpleDictRegistry (Map .empty))
81
87
)
82
88
83
- val processResolverByProcessingType : ProcessingTypeDataProvider [UIProcessResolver , _] =
84
- mapProcessingTypeDataProvider(Streaming .stringify -> processResolver)
85
-
86
- val scenarioParametersService : ScenarioParametersService = {
87
- val combinations = Map (
88
- TestProcessingType .Streaming .stringify ->
89
- ScenarioParametersWithEngineSetupErrors (
90
- ScenarioParameters (
91
- ProcessingMode .UnboundedStream ,
92
- TestCategory .Category1 .stringify,
93
- EngineSetupName (" Flink" )
94
- ),
95
- List .empty
96
- )
89
+ def processResolverByProcessingType (
90
+ processingTypes : List [String ] = List (Streaming .stringify)
91
+ ): ProcessingTypeDataProvider [UIProcessResolver , _] = {
92
+ val resolver = processResolver(processingTypes)
93
+ mapProcessingTypeDataProvider(processingTypes.map(pt => (pt, resolver)): _* )
94
+ }
95
+
96
+ def scenarioParametersService (
97
+ processingTypes : List [String ] = List (Streaming .stringify)
98
+ ): ScenarioParametersService = {
99
+ val scenarioParameters = ScenarioParametersWithEngineSetupErrors (
100
+ ScenarioParameters (
101
+ ProcessingMode .UnboundedStream ,
102
+ TestCategory .Category1 .stringify,
103
+ EngineSetupName (" Flink" )
104
+ ),
105
+ List .empty
97
106
)
107
+ val combinations = processingTypes.map(pt => (pt, scenarioParameters)).toMap
98
108
ScenarioParametersService .createUnsafe(combinations)
99
109
}
100
110
101
- val scenarioParametersServiceProvider : ProcessingTypeDataProvider [_, ScenarioParametersService ] =
102
- TestProcessingTypeDataProviderFactory .create(Map .empty, scenarioParametersService)
111
+ def scenarioParametersServiceProvider (
112
+ processingTypes : List [String ] = List (Streaming .stringify)
113
+ ): ProcessingTypeDataProvider [_, ScenarioParametersService ] =
114
+ TestProcessingTypeDataProviderFactory .create(Map .empty, scenarioParametersService(processingTypes))
103
115
104
116
// It should be defined as method, because when it's defined as val then there is bug in IDEA at DefinitionPreparerSpec - it returns null
105
- def prepareSampleFragmentRepository : StubFragmentRepository = new StubFragmentRepository (
106
- Map (
107
- Streaming .stringify -> List (ProcessTestData .sampleFragment)
117
+ def prepareSampleFragmentRepository (
118
+ processingTypes : List [String ] = List (Streaming .stringify)
119
+ ): StubFragmentRepository =
120
+ new StubFragmentRepository (
121
+ processingTypes.map(pt => (pt, List (ProcessTestData .sampleFragment))).toMap
108
122
)
109
- )
110
123
111
- def sampleResolver = new FragmentResolver (prepareSampleFragmentRepository)
124
+ def sampleResolver (processingTypes : List [String ] = List (Streaming .stringify)) =
125
+ new FragmentResolver (prepareSampleFragmentRepository(processingTypes))
112
126
113
- val scenarioResolver = new ScenarioResolver (sampleResolver, Streaming .stringify)
127
+ def scenarioResolver (processingType : String = Streaming .stringify) =
128
+ new ScenarioResolver (sampleResolver(processingType :: Nil ), processingType)
114
129
115
- def scenarioResolverByProcessingType : ProcessingTypeDataProvider [ScenarioResolver , _] =
116
- mapProcessingTypeDataProvider(
117
- Streaming .stringify -> scenarioResolver
118
- )
130
+ def scenarioResolverByProcessingType (
131
+ processingTypes : List [String ] = List (Streaming .stringify)
132
+ ): ProcessingTypeDataProvider [ScenarioResolver , _] = {
133
+ mapProcessingTypeDataProvider(processingTypes.map(pt => (pt, scenarioResolver(pt))): _* )
134
+ }
119
135
120
136
def additionalComponentConfigsByProcessingType
121
137
: ProcessingTypeDataProvider [Map [DesignerWideComponentId , ComponentAdditionalConfig ], _] =
@@ -160,24 +176,32 @@ object TestFactory {
160
176
new DBFetchingProcessRepository [DB ](dbRef, newActionProcessRepository(dbRef), newScenarioLabelsRepository(dbRef))
161
177
with DbioRepository
162
178
163
- def newWriteProcessRepository (dbRef : DbRef , clock : Clock , modelVersions : Option [Int ] = Some (1 )) =
179
+ def newWriteProcessRepository (
180
+ dbRef : DbRef ,
181
+ clock : Clock ,
182
+ processingTypes : List [String ] = List (Streaming .stringify),
183
+ modelVersions : Option [Int ] = Some (1 )
184
+ ) =
164
185
new DBProcessRepository (
165
186
dbRef,
166
187
clock,
167
188
newScenarioActivityRepository(dbRef, clock),
168
189
newScenarioLabelsRepository(dbRef),
169
- mapProcessingTypeDataProvider(modelVersions.map(Streaming .stringify -> _) .toList: _* ),
190
+ mapProcessingTypeDataProvider(modelVersions.map(mv => processingTypes.map(pt => (pt, mv))) .toList.flatten : _* ),
170
191
)
171
192
172
193
def newDummyWriteProcessRepository (): DBProcessRepository =
173
194
newWriteProcessRepository(dummyDbRef, Clock .systemUTC())
174
195
175
- def newScenarioGraphVersionService (dbRef : DbRef ) = new ScenarioGraphVersionService (
176
- newScenarioGraphVersionRepository(dbRef),
177
- mapProcessingTypeDataProvider(Streaming .stringify -> processValidator),
178
- scenarioResolverByProcessingType,
179
- newDBIOActionRunner(dbRef)
180
- )
196
+ def newScenarioGraphVersionService (dbRef : DbRef , processingTypes : List [String ] = List (Streaming .stringify)) = {
197
+ val validator = processValidator(processingTypes)
198
+ new ScenarioGraphVersionService (
199
+ newScenarioGraphVersionRepository(dbRef),
200
+ mapProcessingTypeDataProvider(processingTypes.map(pt => (pt, validator)): _* ),
201
+ scenarioResolverByProcessingType(processingTypes),
202
+ newDBIOActionRunner(dbRef)
203
+ )
204
+ }
181
205
182
206
def newScenarioGraphVersionRepository (dbRef : DbRef ) = new ScenarioGraphVersionRepository (dbRef)
183
207
@@ -197,17 +221,17 @@ object TestFactory {
197
221
def asAdmin (route : RouteWithUser ): Route =
198
222
route.securedRouteWithErrorHandling(adminUser())
199
223
200
- val newProcessPreparer : NewProcessPreparer =
224
+ def newProcessPreparer ( processingType : String = Streaming .stringify) : NewProcessPreparer =
201
225
new NewProcessPreparer (
202
226
ProcessTestData .streamingTypeSpecificInitialData,
203
227
FlinkStreamingPropertiesConfig .properties,
204
- new ScenarioPropertiesConfigFinalizer (TestAdditionalUIConfigProvider , Streaming .stringify )
228
+ new ScenarioPropertiesConfigFinalizer (TestAdditionalUIConfigProvider , processingType )
205
229
)
206
230
207
- val newProcessPreparerByProcessingType : ProcessingTypeDataProvider [ NewProcessPreparer , _] =
208
- mapProcessingTypeDataProvider(
209
- Streaming .stringify -> newProcessPreparer
210
- )
231
+ def newProcessPreparerByProcessingType (
232
+ processingTypes : List [ String ] = List ( Streaming .stringify)
233
+ ) : ProcessingTypeDataProvider [ NewProcessPreparer , _] =
234
+ mapProcessingTypeDataProvider(processingTypes.map(pt => (pt, newProcessPreparer(pt))) : _* )
211
235
212
236
def withPermissions (route : RouteWithUser , permissions : Permission .Permission * ): Route =
213
237
route.securedRouteWithErrorHandling(user(permissions = permissions))
0 commit comments