MongoDbBasicValidation implements StepValidation { @Override public void checkStep( CheckStepsExtension checkStepExtension, DataServiceMeta dataServiceMeta, LogChannelInterface log ) { StepMeta stepMeta = checkStepExtension.getStepMetas()[0]; List<CheckResultInterface> remarks = checkStepExtension.getRemarks(); MongoDbInputMeta mongoDbMeta = (MongoDbInputMeta) checkStepExtension.getStepMetas()[0].getStepMetaInterface(); VariableSpace space = checkStepExtension.getVariableSpace(); checkOutputJson( stepMeta, remarks, mongoDbMeta ); checkPushdownParameter( stepMeta, remarks, mongoDbMeta, space ); checkParameterGenerationOptimizedMeta( checkStepExtension, dataServiceMeta, log ); }  @Override boolean supportsStep( StepMeta step, LogChannelInterface log ); @Override void checkStep(
      CheckStepsExtension checkStepExtension, DataServiceMeta dataServiceMeta, LogChannelInterface log );  }
@Test public void testCheckNoParamJsonQueryisNull() { mongoDbBasicValidation.checkStep( checkStepsExtension, dataServiceMeta, log ); verify( remarks, times( 1 ) ).add( any( CheckResultInterface.class ) ); }
@Test public void testCheckJsonOutputType() { when( mongoDbInputMeta.getOutputJson() ) .thenReturn( true ); mongoDbBasicValidation.checkStep( checkStepsExtension, dataServiceMeta, log ); verify( remarks, times( 2 ) ).add( any( CheckResultInterface.class ) ); }
@Test public void testCheckNoParam() { when( mongoDbInputMeta.getJsonQuery() ).thenReturn( "{$unwind : 'foo'}" ); mongoDbBasicValidation.checkStep( checkStepsExtension, dataServiceMeta, log ); verify( remarks, times( 1 ) ).add( any( CheckResultInterface.class ) ); }
@Test public void testCheckNoWarningsWithParam() { when( mongoDbInputMeta.getJsonQuery() ).thenReturn( "{$unwind : 'foo'}, {$match : ${baz}}" ); space.setVariable( "baz", "foo='123'" ); mongoDbBasicValidation.checkStep( checkStepsExtension, dataServiceMeta, log ); verify( remarks, never() ).add( any( CheckResultInterface.class ) ); }
@Test public void testCheckNoParamForDefinedOpt() { when( mongoDbInputMeta.getJsonQuery() ).thenReturn( "{$unwind : 'foo'}" ); setupMockedParamGen( "testParam", "testStep" ); when( stepMeta.getName() ) .thenReturn( "testStep" ); mongoDbBasicValidation.checkStep( checkStepsExtension, dataServiceMeta, log ); verify( remarks, times( 2 ) ).add( any( CheckResultInterface.class ) ); }
@Test public void testCheckOkWithParam() { when( mongoDbInputMeta.getJsonQuery() ).thenReturn( "{$unwind : 'foo'}, {$match : ${testParam}}" ); space.setVariable( "testParam", "{foo :'123'}" ); setupMockedParamGen( "testParam", "testStep" ); when( stepMeta.getName() ) .thenReturn( "testStep" ); mongoDbBasicValidation.checkStep( checkStepsExtension, dataServiceMeta, log ); verify( remarks, never() ).add( any( CheckResultInterface.class ) ); }