// Path: parent/bundles/com.google.eclipse.mechanic/src/com/google/eclipse/mechanic/IResourceTaskReference.java
// public interface IResourceTaskReference {
//   /** Return the name of the task reference. This is typically a local name. */
//   String getName();
// 
//   /** Return the task reference as an input stream. */
//   InputStream newInputStream() throws IOException;
// 
//   /**
//    * Return the time this resource was last modified, in milliseconds since the epoch.
//    */
//   long getLastModified() throws IOException;
// 
//   /** 
//    * Return the task reference path. Provide enough metadata to give it some distinction,
//    * separate from other providers.
//    */
//   String getPath();
// 
//   /**
//    * Return the File representation of this resource. Is {@code null} it's not a File.
//    */
//   File asFile();
// 
//   /**
//    * Return the MD5 hash of this task
//    */
//   long computeMD5() throws IOException;
// }
// 
// Path: parent/bundles/com.google.eclipse.mechanic/src/com/google/eclipse/mechanic/ListCollector.java
// public class ListCollector<T> implements ICollector<T> {
//   private final List<T> list = Lists.newArrayList();
// 
//   public static <T> ListCollector<T> create() {
//     return new ListCollector<T>();
//   }
// 
//   public void collect(T element) {
//     list.add(element);
//   }
// 
//   public List<T> get() {
//     return list;
//   }
// }


import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.net.URI;
import java.util.List;
import junit.framework.TestCase;
import com.google.eclipse.mechanic.IResourceTaskReference;
import com.google.eclipse.mechanic.ListCollector;
import com.google.eclipse.mechanic.tests.internal.RunAsJUnitTest;
/*******************************************************************************
 * Copyright (C) 2011, Google Inc.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/
package com.google.eclipse.mechanic.internal;





/**
 * Tests for (@link {@link UriTaskProvider}.
 *
 */
@RunAsJUnitTest
public class UriTaskProviderTest extends TestCase {
  private static final String CONTENT =
    "{ type : 'com.google.eclipse.mechanic.UriTaskProviderModel', " +
    "metadata : {" +
    "  name: 'green hornet'," +
    "  description: 'i wear green and i fight crime'," +
    "  contact: 'greenhornet.com'" +
    "}, " + 
    "tasks: [" +
    "  'http://www.google.com/foo/bar/baz', " +
    "  'path'," +
    "  'path2'" +
    "]" +
    "} ";

  public void testRelativize() throws Exception {
    URI uri = URI.create("http://www.testuri.com/mechanic/tasks/schema");

    IUriContentProvider cache = mock(IUriContentProvider.class);
    when(cache.get(uri)).thenReturn(asInputStream(CONTENT));

    UriTaskProvider provider = UriTaskProvider.newInstance(uri, cache, cache);
// Path: parent/bundles/com.google.eclipse.mechanic/src/com/google/eclipse/mechanic/IResourceTaskReference.java
// public interface IResourceTaskReference {
//   /** Return the name of the task reference. This is typically a local name. */
//   String getName();
// 
//   /** Return the task reference as an input stream. */
//   InputStream newInputStream() throws IOException;
// 
//   /**
//    * Return the time this resource was last modified, in milliseconds since the epoch.
//    */
//   long getLastModified() throws IOException;
// 
//   /** 
//    * Return the task reference path. Provide enough metadata to give it some distinction,
//    * separate from other providers.
//    */
//   String getPath();
// 
//   /**
//    * Return the File representation of this resource. Is {@code null} it's not a File.
//    */
//   File asFile();
// 
//   /**
//    * Return the MD5 hash of this task
//    */
//   long computeMD5() throws IOException;
// }
// 
// Path: parent/bundles/com.google.eclipse.mechanic/src/com/google/eclipse/mechanic/ListCollector.java
// public class ListCollector<T> implements ICollector<T> {
//   private final List<T> list = Lists.newArrayList();
// 
//   public static <T> ListCollector<T> create() {
//     return new ListCollector<T>();
//   }
// 
//   public void collect(T element) {
//     list.add(element);
//   }
// 
//   public List<T> get() {
//     return list;
//   }
// }


// Path: parent/tests/com.google.eclipse.mechanic.tests/src/com/google/eclipse/mechanic/internal/UriTaskProviderTest.java
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.net.URI;
import java.util.List;
import junit.framework.TestCase;
import com.google.eclipse.mechanic.IResourceTaskReference;
import com.google.eclipse.mechanic.ListCollector;
import com.google.eclipse.mechanic.tests.internal.RunAsJUnitTest;

/*******************************************************************************
 * Copyright (C) 2011, Google Inc.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/
package com.google.eclipse.mechanic.internal;





/**
 * Tests for (@link {@link UriTaskProvider}.
 *
 */
@RunAsJUnitTest
public class UriTaskProviderTest extends TestCase {
  private static final String CONTENT =
    "{ type : 'com.google.eclipse.mechanic.UriTaskProviderModel', " +
    "metadata : {" +
    "  name: 'green hornet'," +
    "  description: 'i wear green and i fight crime'," +
    "  contact: 'greenhornet.com'" +
    "}, " + 
    "tasks: [" +
    "  'http://www.google.com/foo/bar/baz', " +
    "  'path'," +
    "  'path2'" +
    "]" +
    "} ";

  public void testRelativize() throws Exception {
    URI uri = URI.create("http://www.testuri.com/mechanic/tasks/schema");

    IUriContentProvider cache = mock(IUriContentProvider.class);
    when(cache.get(uri)).thenReturn(asInputStream(CONTENT));

    UriTaskProvider provider = UriTaskProvider.newInstance(uri, cache, cache);
    ListCollector<IResourceTaskReference> collector = ListCollector.create();