use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.SubmitInstructionInput in project bgpcep by opendaylight.
the class ProgrammingServiceImplTest method testTimeoutWhileScheduledTransaction.
@Test(timeout = 30 * 1000)
public void testTimeoutWhileScheduledTransaction() throws Exception {
final BigInteger deadlineOffset = BigInteger.valueOf(1000L * 1000 * 1000 * INSTRUCTION_DEADLINE_OFFSET_IN_SECONDS);
final Nanotime current = NanotimeUtil.currentTime();
final Nanotime deadlineNano = new Nanotime(current.getValue().add(deadlineOffset));
final Optional<Nanotime> deadline = Optional.of(deadlineNano);
final SubmitInstructionInput mockedSubmit1 = getMockedSubmitInstructionInput("mockedSubmit1", deadline);
final ListenableFuture<Instruction> future = this.testedProgrammingService.scheduleInstruction(mockedSubmit1);
this.mockedNotificationServiceWrapper.assertNotificationsCount(1);
future.get();
this.mockedNotificationServiceWrapper.assertNotificationsCount(2);
this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit1.getId(), InstructionStatus.Cancelled);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.SubmitInstructionInput in project bgpcep by opendaylight.
the class ProgrammingServiceImplTest method testCloseProgrammingService.
@Test
public void testCloseProgrammingService() throws Exception {
final SubmitInstructionInput mockedSubmit1 = getMockedSubmitInstructionInput("mockedSubmit1");
this.testedProgrammingService.scheduleInstruction(mockedSubmit1);
final SubmitInstructionInput mockedSubmit2 = getMockedSubmitInstructionInput("mockedSubmit2", "mockedSubmit1");
this.testedProgrammingService.scheduleInstruction(mockedSubmit2);
this.testedProgrammingService.close();
this.mockedNotificationServiceWrapper.assertNotificationsCount(1 + /* First scheduled */
2);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.SubmitInstructionInput in project bgpcep by opendaylight.
the class ProgrammingServiceImplTest method getMockedSubmitInstructionInput.
private static SubmitInstructionInput getMockedSubmitInstructionInput(final String id, final Optional<Nanotime> deadline, final String... dependencyIds) {
final SubmitInstructionInput mockedSubmitInstruction = mock(SubmitInstructionInput.class);
doReturn(PcepUpdateTunnelInput.class).when(mockedSubmitInstruction).getImplementedInterface();
final List<InstructionId> dependencies = Lists.newArrayList();
for (final String dependencyId : dependencyIds) {
dependencies.add(new InstructionId(dependencyId));
}
doReturn(dependencies).when(mockedSubmitInstruction).getPreconditions();
doReturn(new InstructionId(id)).when(mockedSubmitInstruction).getId();
doReturn(deadline.isPresent() ? deadline.get() : new Nanotime(BigInteger.valueOf(Long.MAX_VALUE))).when(mockedSubmitInstruction).getDeadline();
return mockedSubmitInstruction;
}
Aggregations