@Test
public void testValidationWarningsOnNitfAttributeTransformException() throws Exception {

  String originalNitfValue = "US";
  NitfTestCommons.setupNitfUtilities(originalNitfValue, Arrays.asList("USA", "CAN"));
  File nitfFile = temporaryFolder.newFile("nitf-attribute-header-test.ntf");
  FileSecurityMetadata fileSecurityMetadata = TreUtilityTest.createSecurityMetadata();
  when(fileSecurityMetadata.getSecurityClassificationSystem()).thenReturn(originalNitfValue);
  Supplier<NitfHeader> nitfHeader = () -> TreUtilityTest.createFileHeader(fileSecurityMetadata);
  new NitfCreationFlowImpl().fileHeader(nitfHeader).write(nitfFile.getAbsolutePath());
  Metacard metacard;
  try (InputStream inputStream = new FileInputStream(nitfFile)) {
    metacard = metacardFactory.createMetacard("nitfHeaderTest");
    NitfSegmentsFlow nitfSegmentsFlow =
        new NitfParserInputFlowImpl().inputStream(inputStream).headerOnly();
    nitfHeaderTransformer.transform(nitfSegmentsFlow, metacard);
  }
  assertThat(metacard, is(not(nullValue())));
  assertThat(
      metacard.getAttribute(Validation.VALIDATION_WARNINGS).getValues().size(), equalTo(1));
  assertThat(
      metacard.getAttribute(Security.CLASSIFICATION_SYSTEM).getValue(), is(originalNitfValue));
}