fix tests according to code review

This commit is contained in:
fjy 2013-08-21 13:23:38 -07:00
parent 54ad854471
commit ac32c6f27c
3 changed files with 23 additions and 10 deletions

View File

@ -96,7 +96,11 @@ public class RealtimeManager implements QuerySegmentWalker
}
public FireDepartmentMetrics getMetrics(String datasource)
{
return chiefs.get(datasource).getMetrics();
FireChief chief = chiefs.get(datasource);
if (chief == null) {
return null;
}
return chief.getMetrics();
}
@Override

View File

@ -31,10 +31,16 @@ public class MessageTimeRejectionPolicyFactoryTest
@Test
public void testAccept() throws Exception
{
RejectionPolicy rejectionPolicy = new MessageTimeRejectionPolicyFactory().create(
new Period("PT10M")
);
Period period = new Period("PT10M");
RejectionPolicy rejectionPolicy = new MessageTimeRejectionPolicyFactory().create(period);
Assert.assertTrue(rejectionPolicy.accept(new DateTime().getMillis()));
DateTime now = new DateTime();
DateTime past = now.minus(period).minus(1);
DateTime future = now.plus(period).plus(1);
Assert.assertTrue(rejectionPolicy.accept(now.getMillis()));
Assert.assertFalse(rejectionPolicy.accept(past.getMillis()));
Assert.assertTrue(rejectionPolicy.accept(future.getMillis()));
Assert.assertFalse(rejectionPolicy.accept(now.getMillis()));
}
}

View File

@ -31,11 +31,14 @@ public class ServerTimeRejectionPolicyFactoryTest
@Test
public void testAccept() throws Exception
{
RejectionPolicy rejectionPolicy = new ServerTimeRejectionPolicyFactory().create(
new Period("PT10M")
);
Period period = new Period("PT10M");
Assert.assertTrue(rejectionPolicy.accept(new DateTime().getMillis()));
Assert.assertFalse(rejectionPolicy.accept(new DateTime("2000").getMillis()));
RejectionPolicy rejectionPolicy = new ServerTimeRejectionPolicyFactory().create(period);
DateTime now = new DateTime();
DateTime past = now.minus(period).minus(1);
Assert.assertTrue(rejectionPolicy.accept(now.getMillis()));
Assert.assertFalse(rejectionPolicy.accept(past.getMillis()));
}
}