/*
 * $HeadURL$
 * $Id$
 * Copyright (c) 2006-2014 by Public Library of Science http://plos.org http://ambraproject.org
 * 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.0Unless 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 org.ambraproject.wombat.util;

import org.testng.annotations.Test;

import java.util.HashMap;
import java.util.Map;

import static org.testng.Assert.assertEquals;

public class DoiSchemeStripperTest {

  @Test
  public void testStrip() throws Exception {
    {
      Map<String, Object> map = new HashMap<>();
      map.put("foo", "fooValue");
      map.put("doi", "info:doi/10.1371/journal.pone.0091290");
      map = DoiSchemeStripper.strip(map);
      assertEquals(map.get("doi"), "10.1371/journal.pone.0091290");
      assertEquals(map.get("foo"), "fooValue");
    }
    {
      Map<String, Object> map = new HashMap<>();
      map.put("doi", "info:doi/10.1234/kjhrnjlrtj/werwljkd");
      map = DoiSchemeStripper.strip(map);
      assertEquals(map.get("doi"), "10.1234/kjhrnjlrtj/werwljkd");
    }
    {
      Map<String, Object> map = new HashMap<>();
      map.put("doi", "10.1234/kjhrnjlrtj/lkjlrtre");
      map = DoiSchemeStripper.strip(map);
      assertEquals(map.get("doi"), "10.1234/kjhrnjlrtj/lkjlrtre");
    }
  }
}

/*
 * $HeadURL$
 * $Id$
 * Copyright (c) 2006-2014 by Public Library of Science http://plos.org http://ambraproject.org
 * 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.0Unless 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 org.ambraproject.wombat.util;

import org.testng.annotations.Test;

import java.util.HashMap;
import java.util.Map;

import static org.testng.Assert.assertEquals;

public class DoiSchemeStripperTest {

  @Test
  public void testMapStrip() throws Exception {
    {
      Map<String, Object> map = new HashMap<>();
      map.put("foo", "fooValue");
      map.put("doi", "info:doi/10.1371/journal.pone.0091290");
      map = DoiSchemeStripper.strip(map);
      assertEquals(map.get("doi"), "10.1371/journal.pone.0091290");
      assertEquals(map.get("foo"), "fooValue");
    }
    {
      Map<String, Object> map = new HashMap<>();
      map.put("doi", "info:doi/10.1234/kjhrnjlrtj/werwljkd");
      map = DoiSchemeStripper.strip(map);
      assertEquals(map.get("doi"), "10.1234/kjhrnjlrtj/werwljkd");
    }
    {
      Map<String, Object> map = new HashMap<>();
      map.put("doi", "10.1234/kjhrnjlrtj/lkjlrtre");
      map = DoiSchemeStripper.strip(map);
      assertEquals(map.get("doi"), "10.1234/kjhrnjlrtj/lkjlrtre");
    }
  }

  @Test
  public void testStringStrip() {
    assertEquals(DoiSchemeStripper.strip("info:doi/10.1371/journal.pone.0091290"), "10.1371/journal.pone.0091290");
    assertEquals(DoiSchemeStripper.strip("fooValue"), "fooValue");
    assertEquals(DoiSchemeStripper.strip("info:doi/10.1234/kjhrnjlrtj/werwljkd"), "10.1234/kjhrnjlrtj/werwljkd");
    assertEquals(DoiSchemeStripper.strip("10.1234/kjhrnjlrtj/lkjlrtre"), "10.1234/kjhrnjlrtj/lkjlrtre");
  }

}

Add unit test for DoiSchemeStripper.strip(String)