/** * Gets extractor config. * * @param clazz the clazz * @return the extractor config */ protected <W> ExtractorConfig<W> getExtractorConfig(Class<W> clazz) { return new ExtractorConfig<>(clazz); }
private ExtractorConfig createS3DeepJobConfig() { ExtractorConfig extractorConfig = new ExtractorConfig(); extractorConfig.setExtractorImplClassName(ExtractorConstants.S3); Map<String, Serializable> values = new HashMap<>(); values.put(ExtractorConstants.FS_FILE_SEPARATOR, ","); values.put(ExtractorConstants.S3_BUCKET, "bucket"); values.put(ExtractorConstants.FS_PREFIX, ExtractorConstants.S3_PREFIX); values.put(ExtractorConstants.FS_FILE_PATH, "/s3test.csv"); values.put(ExtractorConstants.S3_TYPE, ExtractorConstants.S3_TYPE); values.put(ExtractorConstants.CATALOG, ""); values.put(ExtractorConstants.TABLE, ""); extractorConfig.setValues(values); return extractorConfig; }
private ExtractorConfig createHDFSDeepJobConfig() { ExtractorConfig extractorConfig = new ExtractorConfig(); extractorConfig.setExtractorImplClassName("hdfs"); Map<String, Serializable> values = new HashMap<>(); values.put(ExtractorConstants.PORT, "9000"); values.put(ExtractorConstants.FS_FILE_SEPARATOR, ","); values.put(ExtractorConstants.FS_FILE_PATH, "/user/hadoop/test/songs.csv"); values.put(ExtractorConstants.FS_PREFIX, ExtractorConstants.HDFS_PREFIX); values.put(ExtractorConstants.HOST, "127.0.0.1"); values.put(ExtractorConstants.HDFS_TYPE, ExtractorConstants.HDFS_TYPE); values.put(ExtractorConstants.TABLE, ""); values.put(ExtractorConstants.CATALOG, ""); extractorConfig.setValues(values); return extractorConfig; }
@Test public void testGetIntegerWorkArroundPorts() throws Exception { String value = "1234,1234,1234"; ExtractorConfig extractorConfig = new ExtractorConfig(); Map<String, Serializable> values = new HashedMap(); values.put(value,value); extractorConfig.setValues(values); Integer result = extractorConfig.getInteger(value); String expectedValue = value.split(",")[0]; assertEquals("The result must be "+ expectedValue, new Integer(expectedValue),result); }
/** * * Method: getInteger(String key) * */ @Test public void testGetInteger() throws Exception { String value = "1234"; ExtractorConfig extractorConfig = new ExtractorConfig(); Map<String, Serializable> values = new HashedMap(); values.put(value,value); extractorConfig.setValues(values); Integer result = extractorConfig.getInteger(value); assertEquals("The result must be "+value, new Integer(value),result); }
@Test public void cloneObjectWithParentsTest(){ Map<String, Serializable> map = new HashMap<>(); map.put("key1","val1"); map.put("key2","val2"); map.put("key3","val3"); ExtractorConfig<Cells> extractorConfig = new ExtractorConfig(); extractorConfig.setExtractorImplClassName("testExtractor"); extractorConfig.setValues(map); ExtractorConfig<Cells> clone = extractorConfig.clone(); assertEquals(clone.getExtractorImplClassName(), extractorConfig.getExtractorImplClassName()); assertEquals(clone.getValues(), extractorConfig.getValues()); map.remove("key1"); assertEquals(map.size(),2); assertNotEquals(clone.getValues(), extractorConfig.getValues()); }
@Test public void testInitialize() throws Exception { ExtractorConfig<Cells> extractorConfig = new ExtractorConfig<>(Cells.class); extractorConfig.putValue(ExtractorConstants.HOST, testHost); extractorConfig.putValue(ExtractorConstants.PORT, testPort);
@Test public void initConfigTest(){ ExtractorConfig extractorConfig = new ExtractorConfig(); extractorConfig.setExtractorImplClassName("testExtractor"); DeepJobConfig deepJobConfig = new DeepJobConfig(); deepJobConfig.setExtractorImplClassName("testDeepJobConfig"); ChildDeepJobConfig childDeepJobConfig = new ChildDeepJobConfig(); childDeepJobConfig.setExtractorImplClassName("testChildDeepJobConfig"); childDeepJobConfig.setTestFiled("testField"); ChildDeepJobConfig test = initConfig(extractorConfig, new ChildDeepJobConfig()); assertEquals(test.getExtractorImplClassName(), extractorConfig.getExtractorImplClassName()); assertNull(test.getTestFiled()); test = initConfig(deepJobConfig, new ChildDeepJobConfig()); assertEquals(test.getExtractorImplClassName(), deepJobConfig.getExtractorImplClassName()); assertNull(test.getTestFiled()); test = initConfig(childDeepJobConfig, new ChildDeepJobConfig()); assertEquals(test.getExtractorImplClassName(), childDeepJobConfig.getExtractorImplClassName()); assertEquals(test.getTestFiled(), childDeepJobConfig.getTestFiled()); }