ValidatingComponentUpload { public ComponentUpload getComponentUpload() { validate(); return componentUpload; } ValidatingComponentUpload(final UploadDefinition uploadDefinition, final ComponentUpload componentUpload); ComponentUpload getComponentUpload();  }
@Test public void testValidate_noViolations() { when(uploadDefinition.getAssetFields()).thenReturn( Collections.singletonList(new UploadFieldDefinition("foo", false, STRING))); when(uploadDefinition.getComponentFields()).thenReturn( Collections.singletonList(new UploadFieldDefinition("bar", false, STRING))); when(assetUpload.getPayload()).thenReturn(payload); when(assetUpload.getFields()).thenReturn(singletonMap("foo", "fooValue")); when(assetUpload.getField("foo")).thenReturn("fooValue"); when(componentUpload.getAssetUploads()).thenReturn(Collections.singletonList(assetUpload)); when(componentUpload.getFields()).thenReturn(singletonMap("bar", "barValue")); when(componentUpload.getField("bar")).thenReturn("barValue"); try { ValidatingComponentUpload validated = new ValidatingComponentUpload(uploadDefinition, componentUpload); validated.getComponentUpload(); } catch (ValidationErrorsException e) { fail(format("Unexpected validation exception thrown '%s'", e)); } }