@@ -0,0 +1,3575 @@
+/*%0A * The Alluxio Open Foundation licenses this work under the Apache License, version 2.0%0A * (the %E2%80%9CLicense%E2%80%9D). You may not use this work except in compliance with the License, which is%0A * available at www.apache.org/licenses/LICENSE-2.0%0A *%0A * This software is distributed on an %22AS IS%22 basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,%0A * either express or implied, as more fully set forth in the License.%0A *%0A * See the NOTICE file distributed with this work for information regarding copyright ownership.%0A */%0A%0Apackage alluxio.worker.file;%0A%0Aimport alluxio.Configuration;%0Aimport alluxio.underfs.UnderFileSystem;%0A%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.mockito.BDDMockito;%0Aimport org.mockito.Mockito;%0Aimport org.powermock.api.mockito.PowerMockito;%0Aimport org.powermock.core.classloader.annotations.PrepareForTest;%0Aimport org.powermock.modules.junit4.PowerMockRunner;%0A%0Aimport java.io.OutputStream;%0A%0A@RunWith(PowerMockRunner.class)%0A@PrepareForTest(%7BUnderFileSystem.class%7D)%0Apublic class UnderFileSystemManagerTest %7B%0A  /**%0A   * Tests creating a file with the manager will call %7B@link UnderFileSystem#create%7D.%0A   */%0A  @Test%0A  public void createUfsFileTest() throws Exception %7B%0A    UnderFileSystem mockUfs = Mockito.mock(UnderFileSystem.class);%0A    OutputStream mockOutputStream = Mockito.mock(OutputStream.class);%0A    Mockito.when(mockUfs.create(Mockito.anyString())).thenReturn(mockOutputStream);%0A    PowerMockito.mockStatic(UnderFileSystem.class);%0A    BDDMockito.given(UnderFileSystem.get(Mockito.anyString(), Mockito.any(Configuration.class)))%0A        .willReturn(mockUfs);%0A%0A    String testFile = %22test%22;%0A    UnderFileSystemManager manager = new UnderFileSystemManager();%0A    manager.createFile(testFile);%0A    Mockito.verify(mockUfs).create(Mockito.contains(testFile));%0A  %7D%0A%0A  /**%0A   * Tests completing a file with the manager will call %7B@link UnderFileSystem#rename%7D.%0A   */%0A  @Test%0A  public void completeUfsFileTest() throws Exception %7B%0A    UnderFileSystem mockUfs = Mockito.mock(UnderFileSystem.class);%0A    OutputStream mockOutputStream = Mockito.mock(OutputStream.class);%0A    Mockito.when(mockUfs.create(Mockito.anyString())).thenReturn(mockOutputStream);%0A    PowerMockito.mockStatic(UnderFileSystem.class);%0A    BDDMockito.given(UnderFileSystem.get(Mockito.anyString(), Mockito.any(Configuration.class)))%0A        .willReturn(mockUfs);%0A%0A    String testFile = %22test%22;%0A    UnderFileSystemManager manager = new UnderFileSystemManager();%0A    long id = manager.createFile(testFile);%0A    Mockito.verify(mockUfs).create(Mockito.contains(testFile));%0A    manager.completeFile(id);%0A    Mockito.verify(mockUfs).rename(Mockito.contains(testFile), Mockito.eq(testFile));%0A  %7D%0A%0A  /**%0A   * Tests canceling a file with the manager will call %7B@link UnderFileSystem#delete%7D.%0A   */%0A  @Test%0A  public void cancelUfsFileTest() throws Exception %7B%0A    UnderFileSystem mockUfs = Mockito.mock(UnderFileSystem.class);%0A    OutputStream mockOutputStream = Mockito.mock(OutputStream.class);%0A    Mockito.when(mockUfs.create(Mockito.anyString())).thenReturn(mockOutputStream);%0A    PowerMockito.mockStatic(UnderFileSystem.class);%0A    BDDMockito.given(UnderFileSystem.get(Mockito.anyString(), Mockito.any(Configuration.class)))%0A        .willReturn(mockUfs);%0A%0A    String testFile = %22test%22;%0A    UnderFileSystemManager manager = new UnderFileSystemManager();%0A    long id = manager.createFile(testFile);%0A    Mockito.verify(mockUfs).create(Mockito.contains(testFile));%0A    manager.cancelFile(id);%0A    Mockito.verify(mockUfs).delete(Mockito.contains(testFile), Mockito.eq(false));%0A  %7D%0A%7D%0A

Add unit test for UnderFileSystem Manager.