@Test
  public void builderNotSetMonitoringAnnotations_setsEmptyAnnotations() throws Exception {
    FakeMonitoringClient fakeMonitoringClient = new FakeMonitoringClient();
    MutableMonitoringRegistry.globalInstance().clear();
    MutableMonitoringRegistry.globalInstance().registerMonitoringClient(fakeMonitoringClient);
    KeysetHandle keysetHandleWithAnnotations =
        KeysetHandle.newBuilder()
            .addEntry(
                KeysetHandle.generateEntryFromParameters(
                        AesCmacParameters.builder()
                            .setVariant(Variant.TINK)
                            .setKeySizeBytes(32)
                            .setTagSizeBytes(16)
                            .build())
                    .withRandomId()
                    .makePrimary())
            .build();
    byte[] plaintext = "plaintext".getBytes(UTF_8);
    Mac mac = keysetHandleWithAnnotations.getPrimitive(Mac.class);

    // Work triggering various code paths.
    byte[] tag = mac.computeMac(plaintext);
    mac.verifyMac(tag, plaintext);

    // Without annotations, nothing gets logged.
    assertThat(fakeMonitoringClient.getLogEntries()).isEmpty();
    assertThat(fakeMonitoringClient.getLogFailureEntries()).isEmpty();
  }
Tests that when encryption failed an exception is thrown.
java_src/src/test/java/com/google/crypto/tink/KeysetHandleTest.java