Skip to content

Commit

Permalink
Correção menu
Browse files Browse the repository at this point in the history
  • Loading branch information
clagomess committed Jul 19, 2017
1 parent c8b30cb commit c1e0645
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<name>pirilampo</name>
<modelVersion>4.0.0</modelVersion>
<groupId>pirilampo</groupId>
<version>1.1.6</version>
<version>1.1.7</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/br/com/pirilampo/util/ParseMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ private Object walker (Object node){
List<Map<String, String>> nodeCasted = (List<Map<String, String>>) node;

String htmlFeatureId = String.join(" ", nodes);
htmlFeatureId = htmlFeatureId.replace(nodes[level], "");
htmlFeatureId = htmlFeatureId.replace(nodes[nodes.length - 1], "");
htmlFeatureId = htmlFeatureId.trim();
htmlFeatureId = htmlFeatureId + "_" + nodes[level].replace(".feature", "");
htmlFeatureId = htmlFeatureId + "_" + nodes[nodes.length - 1].replace(".feature", "");

Map<String, String> link = new HashMap<>();
link.put("url", htmlFeatureId);
link.put("name", nodes[level].replace(".feature", ""));
link.put("name", nodes[nodes.length - 1].replace(".feature", ""));

if(!nodeCasted.contains(link)) {
nodeCasted.add(link);
Expand All @@ -104,4 +104,8 @@ private Object walker (Object node){

return toReturn;
}

public Map<String, Object> getMenuMap(){
return menu;
}
}
23 changes: 23 additions & 0 deletions src/test/java/CompiladorTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import br.com.pirilampo.main.Main;
import br.com.pirilampo.util.Compilador;
import br.com.pirilampo.util.ParseMenu;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.input.BOMInputStream;
import org.apache.log4j.*;
Expand All @@ -16,6 +17,8 @@
import java.io.*;
import java.util.Base64;
import java.util.Calendar;
import java.util.List;
import java.util.Map;

public class CompiladorTest {
private static final Logger logger = LoggerFactory.getLogger(CompiladorTest.class);
Expand Down Expand Up @@ -576,6 +579,26 @@ public void testCompileTagsExcecoes(){
}
}

@Test
public void testAddMenuItem(){
ParseMenu pm = new ParseMenu();
pm.addMenuItem("Features\\\\001.feature");
pm.addMenuItem("\\bar\\002.feature");
pm.addMenuItem("\\bar\\foo\\003.feature");

Map<String, Object> menu = pm.getMenuMap();

logger.info("MENU: {}", menu);

final String f001 = ((Map<String, String>) ((List) menu.get("Features")).get(0)).get("url");
final String f002 = ((Map<String, String>) ((List) menu.get("bar")).get(0)).get("url");
final String f003 = ((Map<String, String>) ((List) menu.get("bar")).get(1)).get("url");

Assert.assertTrue("Features_001".equals(f001));
Assert.assertTrue("bar_002".equals(f002));
Assert.assertTrue("bar foo_003".equals(f003));
}

@After
public void after() throws Exception {
String outDir = featureDir + File.separator + ".." + File.separator + "html";
Expand Down

0 comments on commit c1e0645

Please sign in to comment.