public TextFileInputMeta() { additionalOutputFields = new BaseFileInputAdditionalField(); inputFiles = new BaseFileInputFiles(); inputFields = new BaseFileField[0]; }
@Test public void whenExportingResourcesWeGetFileObjectsOnlyFromFilesWithNotNullAndNotEmptyFileNames() throws Exception { inputMeta.inputFiles = new BaseFileInputFiles(); inputMeta.inputFiles.fileName = new String[] { FILE_NAME_NULL, FILE_NAME_EMPTY, FILE_NAME_VALID_PATH }; inputMeta.inputFiles.fileMask = new String[] { StringUtil.EMPTY_STRING, StringUtil.EMPTY_STRING, StringUtil.EMPTY_STRING }; inputMeta.exportResources( variableSpace, null, mock( ResourceNamingInterface.class ), null, null ); verify( inputMeta ).getFileObject( FILE_NAME_VALID_PATH, variableSpace ); verify( inputMeta, never() ).getFileObject( FILE_NAME_NULL, variableSpace ); verify( inputMeta, never() ).getFileObject( FILE_NAME_EMPTY, variableSpace ); }
@Test public void testTextFileInputRoundTrip() { // TextFileInputMeta is one of the most complex, including arrays under @InjectionDeep. TextFileInputMeta fileInputMeta = new TextFileInputMeta(); fileInputMeta.inputFields = new BaseFileField[] { new BaseFileField( "foo", 0, 10 ), new BaseFileField( "bar", 0, 10 ) }; fileInputMeta.inputFiles = new BaseFileInputFiles(); final String[] fileNames = { "file1.txt", "file2.tsv" }; fileInputMeta.inputFiles.fileName = fileNames; TextFileInputMeta rehydratedMeta = new TextFileInputMeta(); StepMetaProps props = StepMetaProps.from( fileInputMeta ); MetaXmlSerializer.deserialize( MetaXmlSerializer.serialize( props ) ) .to( rehydratedMeta ); assertThat( rehydratedMeta.inputFields[ 0 ].getName(), equalTo( "foo" ) ); assertThat( rehydratedMeta.inputFields[ 1 ].getName(), equalTo( "bar" ) ); assertThat( rehydratedMeta.inputFiles.fileName, equalTo( fileNames ) ); }
@Test public void testClone() { BaseFileInputFiles orig = new BaseFileInputFiles(); orig.fileName = new String[] { "1", "2" }; orig.fileMask = new String[] { "3", "4" }; orig.excludeFileMask = new String[] { "5", "6" }; orig.fileRequired = new String[] { "7", "8" }; orig.includeSubFolders = new String[] { "9", "0" }; BaseFileInputFiles clone = (BaseFileInputFiles) orig.clone(); assertNotEquals( orig.fileName, clone.fileName ); assertTrue( Arrays.equals( orig.fileName, clone.fileName ) ); assertNotEquals( orig.fileMask, clone.fileMask ); assertTrue( Arrays.equals( orig.fileMask, clone.fileMask ) ); assertNotEquals( orig.excludeFileMask, clone.excludeFileMask ); assertTrue( Arrays.equals( orig.excludeFileMask, clone.excludeFileMask ) ); assertNotEquals( orig.fileRequired, clone.fileRequired ); assertTrue( Arrays.equals( orig.fileRequired, clone.fileRequired ) ); assertNotEquals( orig.includeSubFolders, clone.includeSubFolders ); assertTrue( Arrays.equals( orig.includeSubFolders, clone.includeSubFolders ) ); } }
@Test public void testGetXmlWorksIfWeUpdateOnlyPartOfInputFilesInformation() throws Exception { inputMeta.inputFiles = new BaseFileInputFiles(); inputMeta.inputFiles.fileName = new String[] { FILE_NAME_VALID_PATH }; inputMeta.getXML(); assertEquals( inputMeta.inputFiles.fileName.length, inputMeta.inputFiles.fileMask.length ); assertEquals( inputMeta.inputFiles.fileName.length, inputMeta.inputFiles.excludeFileMask.length ); assertEquals( inputMeta.inputFiles.fileName.length, inputMeta.inputFiles.fileRequired.length ); assertEquals( inputMeta.inputFiles.fileName.length, inputMeta.inputFiles.includeSubFolders.length ); }
@Test public void testClonelWorksIfWeUpdateOnlyPartOfInputFilesInformation() throws Exception { inputMeta.inputFiles = new BaseFileInputFiles(); inputMeta.inputFiles.fileName = new String[] { FILE_NAME_VALID_PATH }; TextFileInputMeta cloned = (TextFileInputMeta) inputMeta.clone(); //since the equals was not override it should be other object assertNotEquals( inputMeta, cloned ); assertEquals( cloned.inputFiles.fileName.length, inputMeta.inputFiles.fileName.length ); assertEquals( cloned.inputFiles.fileMask.length, inputMeta.inputFiles.fileMask.length ); assertEquals( cloned.inputFiles.excludeFileMask.length, inputMeta.inputFiles.excludeFileMask.length ); assertEquals( cloned.inputFiles.fileRequired.length, inputMeta.inputFiles.fileRequired.length ); assertEquals( cloned.inputFiles.includeSubFolders.length, inputMeta.inputFiles.includeSubFolders.length ); assertEquals( cloned.inputFields.length, inputMeta.inputFields.length ); assertEquals( cloned.getFilter().length, inputMeta.getFilter().length ); }