mirror of https://github.com/apache/druid.git
fix tests according to code review
This commit is contained in:
parent
54ad854471
commit
ac32c6f27c
|
@ -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
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue