コード例 #1
0
ファイル: AuditLogger.java プロジェクト: APNIC-net/whois
  public void logUpdate(final Update update) {
    Element updateElement = createOrGetUpdateElement(update);

    int attempt = 1;
    try {
      attempt = Integer.parseInt(updateElement.getAttribute("attempt")) + 1;
      updates.removeChild(updateElement);
      updateElements.remove(update);

      updateElement = createOrGetUpdateElement(update);
    } catch (NumberFormatException ignored) {
    }

    updateElement.setAttribute("attempt", String.valueOf(attempt));
    updateElement.setAttribute(
        "time", FormatHelper.dateTimeToString(dateTimeProvider.getCurrentDateTime()));

    final RpslObject updatedObject = update.getSubmittedObject();
    updateElement.appendChild(keyValue("key", updatedObject.getFormattedKey()));
    updateElement.appendChild(keyValue("operation", update.getOperation().name()));
    updateElement.appendChild(
        keyValue("reason", StringUtils.join(update.getDeleteReasons(), ", ")));
    updateElement.appendChild(keyValue("paragraph", update.getParagraph().getContent()));
    updateElement.appendChild(keyValue("object", updatedObject.toString()));
  }
コード例 #2
0
ファイル: UpdateLogTest.java プロジェクト: GaetanJUVIN/whois
  @Test
  public void logUpdateResult_create_success_dryRun() {
    final RpslObject maintainer = RpslObject.parse("mntner: TST-MNT");
    final UpdateResult updateResult =
        new UpdateResult(
            maintainer,
            maintainer,
            Action.CREATE,
            UpdateStatus.SUCCESS,
            new ObjectMessages(),
            0,
            true);
    when(update.getCredentials()).thenReturn(new Credentials());
    when(updateContext.createUpdateResult(update)).thenReturn(updateResult);

    subject.logUpdateResult(updateRequest, updateContext, update, stopwatch);

    verify(logger)
        .info(
            matches(
                "\\[\\s*0\\] 0[,.]000 ns   DRY CREATE mntner       TST-MNT                        \\(1\\) SUCCESS               : <E0,W0,I0> AUTH  - null"));
  }