JobEntryHadoopCopyFiles extends JobEntryCopyFiles { public String loadURL( String url, String ncName, IMetaStore metastore, Map mappings ) { NamedCluster c = namedClusterService.getNamedClusterByName( ncName, metastore ); String origUrl; String pref = null; if ( url != null && url.indexOf( SOURCE_URL ) > -1 ) { origUrl = url; url = origUrl.substring( origUrl.indexOf( "-", origUrl.indexOf( SOURCE_URL ) + SOURCE_URL.length() ) + 1 ); pref = origUrl.substring( 0, origUrl.indexOf( "-", origUrl.indexOf( SOURCE_URL ) + SOURCE_URL.length() ) + 1 ); } else if ( url != null && url.indexOf( DEST_URL ) > -1 ) { origUrl = url; url = origUrl.substring( origUrl.indexOf( "-", origUrl.indexOf( DEST_URL ) + DEST_URL.length() ) + 1 ); pref = origUrl.substring( 0, origUrl.indexOf( "-", origUrl.indexOf( DEST_URL ) + DEST_URL.length() ) + 1 ); } if ( c != null ) { url = c.processURLsubstitution( url, metastore, getVariables() ); } if ( pref != null ) { url = pref + url; } if ( !Const.isEmpty( ncName ) && !Const.isEmpty( url ) ) { mappings.put( url, ncName ); } return url; } JobEntryHadoopCopyFiles( NamedClusterService namedClusterService,
                                  RuntimeTestActionService runtimeTestActionService, RuntimeTester runtimeTester ); String loadURL( String url, String ncName, IMetaStore metastore, Map mappings ); NamedClusterService getNamedClusterService(); RuntimeTestActionService getRuntimeTestActionService(); RuntimeTester getRuntimeTester(); static final String S3_SOURCE_FILE; static final String S3_DEST_FILE; }
@Test public void testLoadUrlNullNcName() { when( namedClusterManager.getNamedClusterByName( testNcName, metaStore ) ).thenReturn( null ); String loadURL = jobEntryHadoopCopyFiles.loadURL( testUrl, null, metaStore, mappings ); assertNotNull( loadURL ); verifyNoMoreInteractions( mappings ); }
@Test public void testLoadUrlNull() { when( namedClusterManager.getNamedClusterByName( testNcName, metaStore ) ).thenReturn( null ); String loadURL = jobEntryHadoopCopyFiles.loadURL( null, null, metaStore, mappings ); assertNull( loadURL ); verifyNoMoreInteractions( mappings ); }
@Test public void testLoadUrlNotNullForNotCluster() { testNcName = "LOCAL-SOURCE-FILE-1"; when( namedClusterManager.getNamedClusterByName( testNcName, metaStore ) ).thenReturn( null ); String loadURL = jobEntryHadoopCopyFiles.loadURL( testUrl, testNcName, metaStore, mappings ); assertNotNull( loadURL ); assertEquals( testUrl, loadURL ); verify( mappings ).put( testUrl, testNcName ); }
@Test public void testLoadUrlMapRNull() { when( namedClusterManager.getNamedClusterByName( testNcName, metaStore ) ).thenReturn( namedCluster ); when( namedCluster.isMapr() ).thenReturn( true ); assertNull( jobEntryHadoopCopyFiles.loadURL( testUrl, testNcName, metaStore, mappings ) ); verifyNoMoreInteractions( mappings ); }