Exemple #1
0
  private void createTransaction(CreateTransaction createTransaction) {
    try {
      if (TransactionType.fromInt(createTransaction.getTransactionType())
              != TransactionType.READ_ONLY
          && failIfIsolatedLeader(getSender())) {
        return;
      }

      ActorRef transactionActor =
          createTransaction(
              createTransaction.getTransactionType(),
              createTransaction.getTransactionId(),
              createTransaction.getTransactionChainId(),
              createTransaction.getVersion());

      getSender()
          .tell(
              new CreateTransactionReply(
                      Serialization.serializedActorPath(transactionActor),
                      createTransaction.getTransactionId())
                  .toSerializable(),
              getSelf());
    } catch (Exception e) {
      getSender().tell(new akka.actor.Status.Failure(e), getSelf());
    }
  }
  @Test
  public void testToSerializable() {
    TestActorRef<Actor> testActor = factory.createTestActor(MessageCollectorActor.props());
    RegisterChangeListener registerChangeListener =
        new RegisterChangeListener(
            TestModel.TEST_PATH, testActor, AsyncDataBroker.DataChangeScope.BASE);

    ListenerRegistrationMessages.RegisterChangeListener serialized =
        registerChangeListener.toSerializable();

    NormalizedNodeMessages.InstanceIdentifier path = serialized.getInstanceIdentifierPath();

    assertEquals(
        "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", path.getCode(0));
    assertEquals(
        Serialization.serializedActorPath(testActor), serialized.getDataChangeListenerActorPath());
    assertEquals(AsyncDataBroker.DataChangeScope.BASE.ordinal(), serialized.getDataChangeScope());
  }