Exemplo n.º 1
0
  @Test
  public void testGetProtocolVersion() throws Exception {
    Protocol protocol = (Protocol) protocolVersionService.getProtocolVersion(PROTOCOL_NUMBER, 1);
    assertNull(protocol);

    ProtocolDocument protocolDocument1 = ProtocolFactory.createProtocolDocument(PROTOCOL_NUMBER);
    ProtocolDocument protocolDocument2 =
        (ProtocolDocument) protocolVersionService.versionProtocolDocument(protocolDocument1);
    ProtocolDocument protocolDocument3 =
        (ProtocolDocument) protocolVersionService.versionProtocolDocument(protocolDocument2);

    protocol = (Protocol) protocolVersionService.getProtocolVersion(PROTOCOL_NUMBER, 2);
    assertNotNull(protocol);
    assertEquals(new Integer(2), protocol.getSequenceNumber());
  }
Exemplo n.º 2
0
  @Test
  public void testVersioning() throws Exception {
    ProtocolDocument protocolDocument = ProtocolFactory.createProtocolDocument();
    ProtocolDocument newProtocolDocument =
        (ProtocolDocument) protocolVersionService.versionProtocolDocument(protocolDocument);
    assertNotNull(newProtocolDocument);
    assertTrue(
        !StringUtils.equals(
            protocolDocument.getDocumentNumber(), newProtocolDocument.getDocumentNumber()));
    assertTrue(
        (protocolDocument.getProtocol().getSequenceNumber() + 1
            == newProtocolDocument.getProtocol().getSequenceNumber()));
    assertFalse(protocolDocument.getProtocol().isActive());
    assertTrue(newProtocolDocument.getProtocol().isActive());

    List<DocumentNextvalue> nextValues = newProtocolDocument.getDocumentNextvalues();
    for (DocumentNextvalue nextValue : nextValues) {
      assertEquals(nextValue.getDocumentKey(), newProtocolDocument.getDocumentNumber());
    }
  }