/*
 * Copyright (c) 2014 - 2017 the original author or authors.
 *
 * 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 com.github.ferstl.depgraph.dependency.puml;

import org.junit.Test;
import com.github.ferstl.depgraph.dependency.DependencyNode;
import com.github.ferstl.depgraph.dependency.DependencyNodeUtil;

import static org.junit.Assert.assertEquals;

public class PumlDependencyEgdeRendererTest {

  private final PumlDependencyEgdeRenderer renderer = new PumlDependencyEgdeRenderer();

  @Test
  public void testRenderEdgeToIncludeDependency() throws Exception {
    DependencyNode fromNode = DependencyNodeUtil.createDependencyNode("org.springframework",
        "spring-context", "4.3.9-RELEASE");

    DependencyNode toNode = DependencyNodeUtil.createDependencyNode("org.springframework",
        "spring-core", "4.3.9-RELEASE");

    String edgeInfo = this.renderer.render(fromNode, toNode);

    assertEquals("{\"begin\":\"-[\",\"end\":\"]->\",\"color\":\"#000000\",\"label\":\"\"}", edgeInfo);

  }

  @Test
  public void testRenderEdgeToConflictingDependency() throws Exception {
    DependencyNode fromNode = DependencyNodeUtil.createDependencyNode("org.springframework",
        "spring-context", "4.3.9-RELEASE");

    DependencyNode toNode = DependencyNodeUtil.createDependencyNodeWithConflict("commons-logging",
        "commons-logging", "1.1.3");

    String edgeInfo = this.renderer.render(fromNode, toNode);

    assertEquals("{\"begin\":\".[\",\"end\":\"].>\",\"color\":\"#FF0000\",\"label\":\"1.1.3\"}", edgeInfo);
  }
}

@@ -679,26 +679,84 @@
 %0Aimport 
-org.junit.
+com.github.ferstl.depgraph.dependency.AbstractDependencyEdgeRenderer
 Test;%0Aim
@@ -852,83 +852,26 @@
 aph.
-dependency.DependencyNodeUtil;%0A%0Aimport static org.junit.Assert.assertEquals
+graph.EdgeRenderer
 ;%0A%0Ap
@@ -917,31 +917,24 @@
 est 
-%7B%0A%0A  private final Puml
+extends Abstract
 Depe
@@ -932,34 +932,34 @@
 tractDependencyE
-g
 d
+g
 eRenderer render
@@ -955,861 +955,690 @@
 erer
- renderer = new PumlDependencyEgdeRenderer();%0A%0A  @Test%0A  public void testRenderEdgeToIncludeDependency() throws Except
+Test %7B%0A%0A  @Override%0A  protected EdgeRenderer%3CDependencyNode%3E createEdgeRenderer(boolean renderVers
 ion
+)
  %7B%0A    
-DependencyNode fromNode = DependencyNodeUtil.createDependencyNode(%22org.springframework%22,%0A        %22spring-context%22, %224.3.9-RELEASE%22);%0A%0A    DependencyNode toNode = DependencyNodeUtil.createDependencyNode(%22org.springframework%22,%0A        %22spring-core%22, %224.3.9-RELEASE%22);%0A%0A    String edgeInfo = this.renderer.render(fromNode, toNode);%0A%0A    assertEquals(%22%7B%5C%22begin%5C%22:%5C%22-%5B%5C%22,%5C%22end%5C%22:%5C%22%5D-%3E%5C%22,%5C%22color%5C%22:%5C%22#000000%5C%22,%5C%22label%5C%22:%5C%22%5C%22%7D%22, edgeInfo);%0A%0A  %7D%0A%0A  @Test%0A  public void testRenderEdgeToConflictingDependency() throws Exception %7B%0A    DependencyNode fromNode = DependencyNodeUtil.createDependencyNode(%22org.springframework%22,%0A        %22spring-context%22, %224.3.9-RELEASE%22)
+return new PumlDependencyEgdeRenderer();%0A  %7D%0A%0A  @Override%0A  protected String renderWithoutVersionResult() %7B%0A    return %22%7B%5C%22begin%5C%22:%5C%22-%5B%5C%22,%5C%22end%5C%22:%5C%22%5D-%3E%5C%22,%5C%22color%5C%22:%5C%22#000000%5C%22,%5C%22label%5C%22:%5C%22%5C%22%7D%22;%0A  %7D%0A%0A  @Override%0A  protected String renderWithNonConflictingVersionResult() %7B%0A    return %22%7B%5C%22begin%5C%22:%5C%22-%5B%5C%22,%5C%22end%5C%22:%5C%22%5D-%3E%5C%22,%5C%22color%5C%22:%5C%22#000000%5C%22,%5C%22label%5C%22:%5C%22%5C%22%7D%22;%0A  %7D%0A%0A  @Override%0A  protected String renderWithConflictShowingVersionResult() %7B%0A    return %22%7B%5C%22begin%5C%22:%5C%22.%5B%5C%22,%5C%22end%5C%22:%5C%22%5D.%3E%5C%22,%5C%22color%5C%22:%5C%22#FF0000%5C%22,%5C%22label%5C%22:%5C%22version2%5C%22%7D%22
 ;%0A
-%0A
   
-  DependencyNode toNode = DependencyNodeUtil.createDependencyNo
+%7D%0A%0A  @Override%0A  protected String ren
 de
+r
 With
@@ -1649,146 +1649,82 @@
 lict
-(%22commons-logging%22,%0A        %22commons-logging%22, %221.1.3%22);%0A%0A    String edgeInfo = this.renderer.render(fromNode, toNode);%0A%0A    assertEquals(
+NotShowingVersionResult() %7B%0A    // Version is always displayed%0A    return 
 %22%7B%5C%22
@@ -1792,28 +1792,20 @@
 %22:%5C%22
-1.1.3%5C%22%7D%22, edgeInfo)
+version2%5C%22%7D%22
 ;%0A  

Extend AbstractDependencyEdgeRendererTest