/**
 * Copyright 2008 Matthew Hillsdon
 *
 * 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 net.hillsdon.reviki.wiki;

import static java.util.Arrays.asList;

import java.util.Collections;

import net.hillsdon.reviki.vc.impl.PageInfoImpl;
import net.hillsdon.reviki.web.urls.URLOutputFilter;
import junit.framework.TestCase;

public class TestRenderedPage extends TestCase {

  private RenderedPageFactory _factory;

  @Override
  protected void setUp() throws Exception {
    _factory = new RenderedPageFactory(MarkupRenderer.AS_IS);
  }

  private RenderedPage create(String content) throws Exception {
    return _factory.create(new PageInfoImpl("wiki", "FrontPage", content, Collections.<String, String>emptyMap()), URLOutputFilter.NULL);
  }

  public void testGetPage() throws Exception {
    RenderedPage rendered = create("");
    rendered.getPage().equals("FrontPage");
  }

  public void testGetOutgoingLinksExistingPage() throws Exception {
    RenderedPage existingPage = create("<a href='pages/Foo'>Foo</a> to <a class='existing-page other-class' href='pages/Bar'>Bar description</a>");
    assertEquals(asList("Bar"), existingPage.findOutgoingWikiLinks());
  }

  public void testGetOutgoingLinksNewPage() throws Exception {
    RenderedPage newPage = create("<a href='pages/Foo'>Foo</a> to <a class='other-class new-page' href='pages/Bar'>Bar description</a>");
    assertEquals(asList("Bar"), newPage.findOutgoingWikiLinks());
  }

}

@@ -633,48 +633,8 @@
 i;%0A%0A
-import static java.util.Arrays.asList;%0A%0A
 impo
@@ -1357,571 +1357,6 @@
   %7D%0A
-%0A  public void testGetOutgoingLinksExistingPage() throws Exception %7B%0A    RenderedPage existingPage = create(%22%3Ca href='pages/Foo'%3EFoo%3C/a%3E to %3Ca class='existing-page other-class' href='pages/Bar'%3EBar description%3C/a%3E%22);%0A    assertEquals(asList(%22Bar%22), existingPage.findOutgoingWikiLinks());%0A  %7D%0A%0A  public void testGetOutgoingLinksNewPage() throws Exception %7B%0A    RenderedPage newPage = create(%22%3Ca href='pages/Foo'%3EFoo%3C/a%3E to %3Ca class='other-class new-page' href='pages/Bar'%3EBar description%3C/a%3E%22);%0A    assertEquals(asList(%22Bar%22), newPage.findOutgoingWikiLinks());%0A  %7D%0A%0A
 %7D%0A

Remove tests for detecting outgoing links in HTML: it's now done through the AST