/** Test method for {@link CriterionParser#CriterionParser(DatabaseSession, String)}. */ @Test public void testCriterionParserDatabaseSessionString() { assertEquals(mockSession, testParser.getSession()); String[] criterionFields = (String[]) getField(testParser, "fields"); assertArrayEquals(criterionFields, CRITERION_STRING.split(";")); MetricDao dao = (MetricDao) getField(testParser, METRIC_DAO_FIELD); assertEquals(mockSession, dao.getSession()); }
/** Test method for {@link CriterionParser#parse()}. */ @Test public void testParse() { setField(testParser, METRIC_DAO_FIELD, mockMetricDao); when(mockMetricDao.findMetricByName(METRIC_NAME)).thenReturn(METRIC_1); assertSame(METRIC_1, testParser.parse().getMetric()); assertEquals(AMOUNT, testParser.parse().getAmount(), 0); assertEquals(DAYS * 7, testParser.parse().getDays()); }
/** Test method for {@link CriterionParser#parseMetric()}. */ @Test public void testParseMetric() { setField(testParser, METRIC_DAO_FIELD, mockMetricDao); when(mockMetricDao.findMetricByName(METRIC_NAME)).thenReturn(METRIC_1); assertSame(METRIC_1, testParser.parseMetric()); }