ImportYamlGenerator { String getImportYaml(ThemedMapStyle themedMapStyle, int labelLevel, int detailLevel, ThemeColor color) { StringBuilder importBuilder = new StringBuilder() .append("{ import: [ ") .append(themedMapStyle.getBaseStyleFilename()) .append(", "); if (labelLevel != NONE) { importBuilder.append(themedMapStyle.getThemesPath()); importBuilder.append("label-"); importBuilder.append(labelLevel); importBuilder.append(".yaml"); } if (labelLevel != NONE && (detailLevel != NONE || colorExists(color))) { importBuilder.append(", "); } if (detailLevel != NONE) { importBuilder.append(themedMapStyle.getThemesPath()); importBuilder.append("detail-"); importBuilder.append(detailLevel); importBuilder.append(".yaml"); } if (detailLevel != NONE && colorExists(color)) { importBuilder.append(", "); } if (colorExists(color)) { importBuilder.append(themedMapStyle.getThemesPath()); importBuilder.append("color-"); importBuilder.append(color.toString()); importBuilder.append(".yaml"); } importBuilder.append(" ] }"); return importBuilder.toString(); }    }
@Test public void getImportYaml_shouldReturnCorrectString() throws Exception { String yaml = yamlGenerator.getImportYaml(refillStyle, 3, 5, PINK); assertThat(yaml).isEqualTo("{ import: [ refill-style.yaml, themes/label-3.yaml, " + "themes/detail-5.yaml, themes/color-pink.yaml ] }"); }
@Test public void getImportYaml_shouldReturnCorrectStringForNoLod() throws Exception { String yaml = yamlGenerator.getImportYaml(refillStyle, 3, NONE, PINK); assertThat(yaml).isEqualTo("{ import: [ refill-style.yaml, themes/label-3.yaml, " + "themes/color-pink.yaml ] }"); }
@Test public void getImportYaml_shouldReturnCorrectStringForNoColor() throws Exception { String yaml = yamlGenerator.getImportYaml(refillStyle, 3, 8, null); assertThat(yaml).isEqualTo("{ import: [ refill-style.yaml, themes/label-3.yaml, " + "themes/detail-8.yaml ] }"); yamlGenerator.getImportYaml(refillStyle, 3, 8, ThemeColor.NONE); assertThat(yaml).isEqualTo("{ import: [ refill-style.yaml, themes/label-3.yaml, " + "themes/detail-8.yaml ] }"); }
@Test public void getImportYaml_shouldReturnCorrectStringForNoLodNoColor() throws Exception { String yaml = yamlGenerator.getImportYaml(refillStyle, 3, NONE, null); assertThat(yaml).isEqualTo("{ import: [ refill-style.yaml, themes/label-3.yaml ] }"); yamlGenerator.getImportYaml(refillStyle, 3, NONE, ThemeColor.NONE); assertThat(yaml).isEqualTo("{ import: [ refill-style.yaml, themes/label-3.yaml ] }"); }