コード例 #1
0
 /** 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());
 }
コード例 #2
0
 /** 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());
 }
コード例 #3
0
 /** Test method for {@link CriterionParser#parseDays()}. */
 @Test
 public void testParseDays() {
   assertEquals(DAYS * 7, testParser.parseDays());
   testParser = new CriterionParser(mockSession, CRITERION_STRING2);
   assertEquals(DAYS, testParser.parseDays());
 }
コード例 #4
0
 /** Test method for {@link CriterionParser#parseAmount()}. */
 @Test
 public void testParseAmount() {
   assertEquals(AMOUNT, testParser.parseAmount(), 0);
 }
コード例 #5
0
 /** 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());
 }