Search in sources :

Example 6 with ValueProvider

use of org.eclipse.che.api.project.server.type.ValueProvider in project che by eclipse.

the class JavaValueProviderFactoryTest method checkWithErrorInSubfolder.

/**
     * In this case we have an exception while trying to search in sub folders
     */
@Test(expectedExceptions = ValueStorageException.class)
public void checkWithErrorInSubfolder() throws Throwable {
    // we return a file entry that is a javascript file
    FileEntry fileEntry = mock(FileEntry.class);
    when(fileEntry.getName()).thenReturn("helloworld.js");
    when(rootProjectFolder.getChildFiles()).thenReturn(Collections.singletonList(fileEntry));
    FileEntry javaFileEntry = mock(FileEntry.class);
    when(javaFileEntry.getName()).thenThrow(new IllegalStateException("unable to get name of this file"));
    FolderEntry subFolder = mock(FolderEntry.class);
    when(subFolder.getChildFiles()).thenReturn(Collections.singletonList(javaFileEntry));
    when(rootProjectFolder.getChildFolders()).thenReturn(Collections.singletonList(subFolder));
    ValueProvider javaPropertiesValueProvider = new JavaValueProviderFactory().newInstance(rootProjectFolder);
    javaPropertiesValueProvider.getValues(CONTAINS_JAVA_FILES);
    org.testng.Assert.fail("We should have exception reported");
}
Also used : FolderEntry(org.eclipse.che.api.project.server.FolderEntry) FileEntry(org.eclipse.che.api.project.server.FileEntry) ValueProvider(org.eclipse.che.api.project.server.type.ValueProvider) Test(org.testng.annotations.Test)

Aggregations

ValueProvider (org.eclipse.che.api.project.server.type.ValueProvider)6 FileEntry (org.eclipse.che.api.project.server.FileEntry)5 Test (org.testng.annotations.Test)5 FolderEntry (org.eclipse.che.api.project.server.FolderEntry)3 ValueStorageException (org.eclipse.che.api.project.server.type.ValueStorageException)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Attribute (org.eclipse.che.api.core.model.project.type.Attribute)1 AttributeValue (org.eclipse.che.api.project.server.type.AttributeValue)1 Variable (org.eclipse.che.api.project.server.type.Variable)1