/*
 * Copyright (C) 2016 Reece H. Dunn
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package uk.co.reecedunn.intellij.plugin.core.tests.vfs;

import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileSystem;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class ResourceVirtualFile extends VirtualFile {
    private ClassLoader mLoader;
    private String mResource;

    public ResourceVirtualFile(ClassLoader loader, String resource) {
        mLoader = loader;
        mResource = resource;
    }

    public ResourceVirtualFile(String resource) {
        this(ResourceVirtualFile.class.getClassLoader(), resource);
    }

    @NotNull
    @Override
    public String getName() {
        return mResource;
    }

    @NotNull
    @Override
    public VirtualFileSystem getFileSystem() {
        return null;
    }

    @NotNull
    @Override
    public String getPath() {
        return null;
    }

    @Override
    public boolean isWritable() {
        return false;
    }

    @Override
    public boolean isDirectory() {
        return false;
    }

    @Override
    public boolean isValid() {
        return false;
    }

    @Override
    public VirtualFile getParent() {
        return null;
    }

    @Override
    public VirtualFile[] getChildren() {
        return new VirtualFile[0];
    }

    @NotNull
    @Override
    public OutputStream getOutputStream(Object requestor, long newModificationStamp, long newTimeStamp) throws IOException {
        throw new UnsupportedOperationException();
    }

    @NotNull
    @Override
    public byte[] contentsToByteArray() throws IOException {
        return new byte[0];
    }

    @Override
    public long getTimeStamp() {
        return 0;
    }

    @Override
    public long getLength() {
        return 0;
    }

    @Override
    public void refresh(boolean asynchronous, boolean recursive, @Nullable Runnable postRunnable) {
    }

    @Override
    public InputStream getInputStream() throws IOException {
        return mLoader.getResourceAsStream(mResource);
    }
}

@@ -1460,35 +1460,65 @@
 ) %7B%0A        
-return null
+throw new UnsupportedOperationException()
 ;%0A    %7D%0A%0A   
@@ -1575,35 +1575,65 @@
 ) %7B%0A        
-return null
+throw new UnsupportedOperationException()
 ;%0A    %7D%0A%0A   
@@ -1681,36 +1681,65 @@
 ) %7B%0A        
-return false
+throw new UnsupportedOperationException()
 ;%0A    %7D%0A%0A   
@@ -1788,36 +1788,65 @@
 ) %7B%0A        
-return false
+throw new UnsupportedOperationException()
 ;%0A    %7D%0A%0A   
@@ -1899,20 +1899,49 @@
     
-return false
+throw new UnsupportedOperationException()
 ;%0A  
@@ -2008,19 +2008,49 @@
     
-return null
+throw new UnsupportedOperationException()
 ;%0A  
@@ -2121,33 +2121,49 @@
     
-return new VirtualFile%5B0%5D
+throw new UnsupportedOperationException()
 ;%0A  
@@ -2477,26 +2477,49 @@
     
-return new byte%5B0%5D
+throw new UnsupportedOperationException()
 ;%0A  
@@ -2574,32 +2574,65 @@
 ) %7B%0A        
-return 0
+throw new UnsupportedOperationException()
 ;%0A    %7D%0A%0A   
@@ -2684,16 +2684,49 @@
     
-return 0
+throw new UnsupportedOperationException()
 ;%0A  
@@ -2840,24 +2840,75 @@
 Runnable) %7B%0A
+        throw new UnsupportedOperationException();%0A
     %7D%0A%0A    @

Throw UnsupportedOperationException on the methods not currently needed by the tests.