private final KnownOffendersDirectory detective = context.mock(KnownOffendersDirectory.class);
private final Contact contact = context.mock(Contact.class);
@Test public void
lazilyRetrievesJobDetails() {
final JenkinsSpy spy = new JenkinsSpy("myEndpoint", detective, contact);
context.checking(new Expectations() {{
allowing(contact).makeJsonRestCall(with(any(String.class)), with(Server.class));
will(returnValue(serverWithViewsNamed("myFeatureName")));
allowing(contact).makeJsonRestCall(with(any(String.class)), with(ViewDetail.class));
will(returnValue(viewWithJobsNamed("myJob")));
never(contact).makeJsonRestCall(with(any(String.class)), with(JobDetail.class));
}});
final Feature feature = new Feature("myFeatureName", "myEndpoint", new CiServerType("JENKINS"));
final TargetDigestGroup targets = spy.targetsConstituting(feature);
context.assertIsSatisfied();
context.checking(new Expectations() {{
oneOf(contact).makeJsonRestCall(with(any(String.class)), with(JobDetail.class));
will(returnValue(new JobDetail()));
}});
spy.statusOf(targets.iterator().next().id());
context.assertIsSatisfied();
}