package org.ambraproject.wombat.service;

import com.google.common.collect.ImmutableMap;
import com.google.gson.Gson;
import org.ambraproject.wombat.identity.RequestedDoiVersion;
import org.ambraproject.wombat.service.remote.ContentKey;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * used to return article metadata from json files during tests of article controller functionality
 */
public class TestArticleServiceImpl implements ArticleService {
  @Override
  public Map<String, ?> requestArticleMetadata(RequestedDoiVersion articleId, boolean excludeCitations) throws IOException {
    BufferedReader reader = new BufferedReader(
            new FileReader("src/test/resources/articleMeta/" + articleId.getDoi().replace("10.1371/journal.","") + ".json"));
    return (Map<String, Object>) new Gson().fromJson(reader, HashMap.class);
  }

  @Override
  public List<ImmutableMap<String, String>> getArticleFiguresAndTables(Map<?, ?> articleMetadata) {
    ImmutableMap<String, String> asset1 = ImmutableMap.<String, String>builder()
        .put("doi", "info:doi/10.1371/journal.pone.0008083.g001")
        .put("title", "Figure 1")
        .build();
    ImmutableMap<String, String> asset2 = ImmutableMap.<String, String>builder()
        .put("doi", "info:doi/10.1371/journal.pone.0008083.t001")
        .put("title", "Table 1")
        .build();
    ImmutableMap<String, String> asset3 = ImmutableMap.<String, String>builder()
        .put("doi", "info:doi/10.1371/journal.pone.0008083.g002")
        .put("title", "Figure 2")
        .build();
    ImmutableMap<String, String> asset4 = ImmutableMap.<String, String>builder()
        .put("doi", "info:doi/10.1371/journal.pone.0008083.g003")
        .put("title", "Figure 3")
        .build();
    return Arrays.asList(asset1, asset2, asset3, asset4);
  }

  @Override
  public ContentKey getManuscriptKey(RequestedDoiVersion articleId) throws IOException {
    throw new UnsupportedOperationException();
  }
}

@@ -107,24 +107,80 @@
 .gson.Gson;%0A
+import org.ambraproject.wombat.identity.ArticlePointer;%0A
 import org.a
@@ -2156,11 +2156,159 @@
 n();%0A  %7D
+%0A%0A  @Override%0A  public Map%3CString, ?%3E getItemTable(ArticlePointer articleId) throws IOException %7B%0A    throw new UnsupportedOperationException();%0A  %7D
 %0A%7D%0A

Fix compile-time error in unit test