RawUploadHandlerSupport extends UploadHandlerSupport { @Override public UploadDefinition getDefinition() { if (definition == null) { definition = getDefinition(RawFormat.NAME, true, singletonList(new UploadFieldDefinition(DIRECTORY, DIRECTORY_HELP_TEXT, false, Type.STRING, FIELD_GROUP_NAME)), singletonList(new UploadFieldDefinition(FILENAME, false, Type.STRING)), new UploadRegexMap("(.*)", FILENAME)); } return definition; } RawUploadHandlerSupport(
      final ContentPermissionChecker contentPermissionChecker,
      final VariableResolverAdapter variableResolverAdapter,
      final Set<UploadDefinitionExtension> uploadDefinitionExtensions); @Override UploadResponse handle(final Repository repository, final ComponentUpload upload); @Override Content handle(
      final Repository repository,
      final File content,
      final String path); @Override UploadDefinition getDefinition(); @Override VariableResolverAdapter getVariableResolverAdapter(); @Override ContentPermissionChecker contentPermissionChecker(); @Override boolean supportsExportImport();  }
@Test public void testGetDefinition() { UploadDefinition def = underTest.getDefinition(); assertThat(def.isMultipleUpload(), is(true)); assertThat(def.getComponentFields(), contains(field("directory", "Directory", "Destination for uploaded files (e.g. /path/to/files/)", false, STRING, "Component attributes"))); assertThat(def.getAssetFields(), contains(field("filename", "Filename", null, false, STRING, null))); }
@Test public void testGetDefinitionWithExtensionContributions() { underTest = newRawUploadHandler(contentPermissionChecker, new SimpleVariableResolverAdapter(), getDefinitionExtensions()); UploadDefinition def = underTest.getDefinition(); assertThat(def.getComponentFields(), contains( field("directory", "Directory", "Destination for uploaded files (e.g. /path/to/files/)", false, STRING, "Component attributes"), field("foo", "Foo", null, true, STRING, "bar"))); assertThat(def.getAssetFields(), contains(field("filename", "Filename", null, false, STRING, null))); }
@Test public void testGetDefinition_regex() { UploadRegexMap regexMap = underTest.getDefinition().getRegexMap(); assertNotNull(regexMap); assertNotNull(regexMap.getRegex()); assertThat(regexMap.getFieldList(), contains("filename")); }