AMBARI-19045 Remove unnecessary Log Feeder Date Mapper tests Change-Id: Ia8d613c0c53bff04c5ccee0579a337b8cbb3a00a
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/dc5f4e25 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/dc5f4e25 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/dc5f4e25 Branch: refs/heads/branch-dev-patch-upgrade Commit: dc5f4e259ce0f83a3a648de54468f6dadacd5291 Parents: 195b745 Author: Miklos Gergely <mgerg...@hortonworks.com> Authored: Thu Dec 1 11:43:28 2016 +0100 Committer: Miklos Gergely <mgerg...@hortonworks.com> Committed: Thu Dec 1 11:43:28 2016 +0100 ---------------------------------------------------------------------- .../ambari/logfeeder/mapper/MapperDateTest.java | 56 -------------------- 1 file changed, 56 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/dc5f4e25/ambari-logsearch/ambari-logsearch-logfeeder/src/test/java/org/apache/ambari/logfeeder/mapper/MapperDateTest.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-logfeeder/src/test/java/org/apache/ambari/logfeeder/mapper/MapperDateTest.java b/ambari-logsearch/ambari-logsearch-logfeeder/src/test/java/org/apache/ambari/logfeeder/mapper/MapperDateTest.java index 667c9ff..08680f6 100644 --- a/ambari-logsearch/ambari-logsearch-logfeeder/src/test/java/org/apache/ambari/logfeeder/mapper/MapperDateTest.java +++ b/ambari-logsearch/ambari-logsearch-logfeeder/src/test/java/org/apache/ambari/logfeeder/mapper/MapperDateTest.java @@ -141,60 +141,4 @@ public class MapperDateTest { assertEquals("Invalid value wasn't returned as it is", invalidValue, mappedValue); assertTrue("jsonObj is not empty", jsonObj.isEmpty()); } - - @Test - public void testMapperDate_patternWithoutYear_previousYearLog() throws Exception { - LOG.info("testMapperDate_patternWithoutYear_previousYearLog()"); - String fieldName = "logtime"; - Calendar currentCalendar = Calendar.getInstance(); - Map<String, Object> mapConfigs = new HashMap<>(); - mapConfigs.put("target_date_pattern", "yyyy-MM-dd HH:mm:ss.SSS"); - String srcDatePattern ="MMM dd HH:mm:ss"; - mapConfigs.put("src_date_pattern", srcDatePattern); - MapperDate mapperDate = new MapperDate(); - assertTrue("Could not initialize!", mapperDate.init(null, fieldName, null, mapConfigs)); - Map<String, Object> jsonObj = new HashMap<>(); - Calendar nextMonthCalendar = Calendar.getInstance(); - - nextMonthCalendar.set(Calendar.MONTH, currentCalendar.get(Calendar.MONTH)+1 ); - String inputDateStr = new SimpleDateFormat("MMM").format(nextMonthCalendar.getTime()) + " 01 12:01:45"; - Object mappedValue = mapperDate.apply(jsonObj, inputDateStr); - Date mappedDateValue = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").parse(mappedValue.toString()); - String mappedDateValueStr = new SimpleDateFormat(srcDatePattern).format(mappedDateValue); - assertEquals(Date.class, mappedDateValue.getClass()); - - int expectedLogYear = currentCalendar.get(Calendar.YEAR)-1; - Calendar mapppedValueCalendar = Calendar.getInstance(); - mapppedValueCalendar.setTime(mappedDateValue); - assertEquals("Mapped year wasn't matched properly", expectedLogYear, mapppedValueCalendar.get(Calendar.YEAR)); - assertEquals("Mapped date wasn't matched properly", inputDateStr, mappedDateValueStr); - assertEquals("Value wasn't put into jsonObj",mappedValue, jsonObj.remove(fieldName)); - assertTrue("jsonObj is not empty", jsonObj.isEmpty()); - } - - @Test - public void testMapperDate_patternWithoutYear_currentYearLog() throws Exception { - LOG.info("testMapperDate_patternWithoutYear_currentYearLog()"); - String fieldName = "logtime"; - Calendar currentCalendar = Calendar.getInstance(); - Map<String, Object> mapConfigs = new HashMap<>(); - mapConfigs.put("target_date_pattern", "yyyy-MM-dd HH:mm:ss.SSS"); - String srcDatePattern ="MMM dd HH:mm:ss"; - mapConfigs.put("src_date_pattern", srcDatePattern); - MapperDate mapperDate = new MapperDate(); - assertTrue("Could not initialize!", mapperDate.init(null, fieldName, null, mapConfigs)); - Map<String, Object> jsonObj = new HashMap<>(); - String inputDateStr = new SimpleDateFormat("MMM").format(currentCalendar.getTime()) + " 01 12:01:45"; - Object mappedValue = mapperDate.apply(jsonObj, inputDateStr); - Date mappedDateValue = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").parse(mappedValue.toString()); - String mappedDateValueStr = new SimpleDateFormat(srcDatePattern).format(mappedDateValue); - assertEquals(Date.class, mappedDateValue.getClass()); - int expectedLogYear = currentCalendar.get(Calendar.YEAR); - Calendar mapppedValueCalendar = Calendar.getInstance(); - mapppedValueCalendar.setTime(mappedDateValue); - assertEquals("Mapped year wasn't matched properly", expectedLogYear, mapppedValueCalendar.get(Calendar.YEAR)); - assertEquals("Mapped date wasn't matched properly", inputDateStr, mappedDateValueStr); - assertEquals("Value wasn't put into jsonObj",mappedValue, jsonObj.remove(fieldName)); - assertTrue("jsonObj is not empty", jsonObj.isEmpty()); - } }