TdOperatorFactory implements OperatorFactory { public String getType() { return "td"; } @Inject  TdOperatorFactory(TemplateEngine templateEngine, @Environment Map<String, String> env, Config systemConfig); String getType(); @Override Operator newOperator(OperatorContext context);  }
@Test public void testTDJobRequestParams() throws Exception { Path projectPath = Paths.get("").normalize().toAbsolutePath(); Config config = newConfig() .set("database", "testdb") .set("query", "select 1") .set("engine", "presto"); when(op.submitNewJobWithRetry(any(TDJobRequest.class))).thenReturn(""); when(op.getDatabase()).thenReturn("testdb"); ArgumentCaptor<TDJobRequest> captor = ArgumentCaptor.forClass(TDJobRequest.class); TDJobRequest jobRequest = testTDJobRequestParams(projectPath, config); assertEquals("testdb", jobRequest.getDatabase()); assertEquals("select 1", jobRequest.getQuery()); assertEquals("presto", jobRequest.getType().toString() ); assertEquals(Optional.absent(), jobRequest.getEngineVersion()); }
@Test public void testTDJobRequestParamsWithEngineVersion() throws Exception { Path projectPath = Paths.get("").normalize().toAbsolutePath(); Config config = newConfig() .set("database", "testdb") .set("query", "select 1") .set("engine", "hive") .set("engine_version", "stable"); when(op.submitNewJobWithRetry(any(TDJobRequest.class))).thenReturn(""); when(op.getDatabase()).thenReturn("testdb"); TDJobRequest jobRequest = testTDJobRequestParams(projectPath, config); assertEquals("testdb", jobRequest.getDatabase()); assertEquals("select 1", jobRequest.getQuery()); assertEquals("hive", jobRequest.getType().toString() ); assertTrue(jobRequest.getEngineVersion().isPresent()); assertEquals("stable", jobRequest.getEngineVersion().get().toString()); }