Skip to content

Commit 9cfa11a

Browse files
authored
815 remove emojis from cli (#816)
* cleanup: Deprecate method * cleanup: Remove emojis from CLI
1 parent 4fa3ea8 commit 9cfa11a

File tree

3 files changed

+15
-83
lines changed

3 files changed

+15
-83
lines changed

applications/spring-shell/src/main/java/org/springframework/sbm/shell/RecipeRenderer.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import org.jline.utils.AttributedStyle;
2121
import org.jline.utils.Colors;
2222
import org.springframework.sbm.engine.recipe.Recipe;
23-
import org.springframework.sbm.engine.recipe.RecipeAutomation;
2423
import org.springframework.stereotype.Component;
2524

2625
import java.util.List;
@@ -40,8 +39,6 @@ public AttributedString renderRecipesList(String noRecipesTitle, String title, L
4039
AttributedString titleString = renderTitle(title);
4140
builder.append(titleString);
4241

43-
AttributedString emojiMapping = renderEmojiMapping();
44-
builder.append(emojiMapping);
4542
foundRecipes.forEach(recipe -> this.buildRecipePresentation(builder, recipe));
4643

4744
builder.append("\n");
@@ -51,21 +48,12 @@ public AttributedString renderRecipesList(String noRecipesTitle, String title, L
5148
return builder.toAttributedString();
5249
}
5350

54-
public AttributedString renderEmojiMapping() {
55-
AttributedStringBuilder builder = new AttributedStringBuilder();
56-
builder.append(RecipeRenderer.AUTOMATED_EMOJI + " = 'automated recipe'\n");
57-
builder.append(RecipeRenderer.MANUAL_EMOJI + " " + RecipeRenderer.AUTOMATED_EMOJI + " = 'partially automated recipe'\n");
58-
builder.append(RecipeRenderer.MANUAL_EMOJI + " = 'manual recipe'\n\n");
59-
return builder.toAttributedString();
60-
}
61-
6251
public AttributedStringBuilder buildRecipePresentation(AttributedStringBuilder builder, Recipe recipe) {
6352
builder.style(AttributedStyle.DEFAULT);
6453
builder.append(" - ");
6554
builder.style(AttributedStyle.DEFAULT.italicDefault().boldDefault().foreground(Colors.rgbColor("yellow")));
6655
builder.append(recipe.getName());
6756
builder.style(AttributedStyle.DEFAULT);
68-
builder.append(" [").append(getAutomationEmoji(recipe.getAutomationInfo())).append("]");
6957
builder.append("\n -> ").append(recipe.getDescription());
7058
builder.append("\n");
7159
return builder;
@@ -79,12 +67,4 @@ private AttributedString renderTitle(String title) {
7967
builder.append("\n\n");
8068
return builder.toAttributedString();
8169
}
82-
83-
private String getAutomationEmoji(RecipeAutomation recipeAutomation) {
84-
return switch (recipeAutomation) {
85-
case AUTOMATED -> AUTOMATED_EMOJI;
86-
case PARTIALLY_AUTOMATED -> MANUAL_EMOJI + " " + AUTOMATED_EMOJI;
87-
default -> MANUAL_EMOJI;
88-
};
89-
}
9070
}

applications/spring-shell/src/test/java/org/springframework/sbm/shell/RecipeRendererTest.java

Lines changed: 9 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@
1515
*/
1616
package org.springframework.sbm.shell;
1717

18-
import org.springframework.sbm.engine.recipe.Recipe;
19-
import org.springframework.sbm.engine.recipe.RecipeAutomation;
2018
import org.jline.utils.AttributedString;
2119
import org.jline.utils.AttributedStringBuilder;
2220
import org.jline.utils.AttributedStyle;
2321
import org.jline.utils.Colors;
2422
import org.junit.jupiter.api.Test;
2523
import org.junit.jupiter.api.extension.ExtendWith;
2624
import org.mockito.junit.jupiter.MockitoExtension;
25+
import org.springframework.sbm.engine.recipe.Recipe;
2726

2827
import java.util.Collections;
2928
import java.util.List;
@@ -37,82 +36,30 @@ class RecipeRendererTest {
3736
RecipeRenderer sut = new RecipeRenderer();
3837

3938
@Test
40-
void shouldRenderRecipeWithManualEmoji() {
39+
void shouldRenderRecipe() {
4140

4241
Recipe recipe = mock(Recipe.class);
4342
String recipeName = "recipe-1";
4443
String recipeDescription = "the description";
4544

4645
when(recipe.getName()).thenReturn(recipeName);
4746
when(recipe.getDescription()).thenReturn(recipeDescription);
48-
when(recipe.getAutomationInfo()).thenReturn(RecipeAutomation.MANUAL);
49-
5047

5148
AttributedStringBuilder builder = new AttributedStringBuilder();
5249
builder.style(AttributedStyle.DEFAULT);
5350
builder.append(" - ");
54-
builder.style(AttributedStyle.DEFAULT.italicDefault().boldDefault().foreground(Colors.rgbColor("yellow")));
51+
builder.style(AttributedStyle.DEFAULT.boldDefault().foreground(Colors.rgbColor("yellow")));
5552
builder.append(recipe.getName());
5653
builder.style(AttributedStyle.DEFAULT);
57-
builder.append(" [" + RecipeRenderer.MANUAL_EMOJI + "]");
5854
builder.append("\n -> " + recipe.getDescription());
5955
builder.append("\n");
6056

6157
AttributedStringBuilder builder2 = new AttributedStringBuilder();
62-
assertThat(sut.buildRecipePresentation(builder2, recipe).toAttributedString())
63-
.isEqualTo(builder.toAttributedString());
64-
}
65-
66-
@Test
67-
void shouldRenderRecipeWithAutomatedEmoji() {
68-
69-
Recipe recipe = mock(Recipe.class);
70-
String recipeName = "recipe-1";
71-
String recipeDescription = "the description";
72-
73-
when(recipe.getName()).thenReturn(recipeName);
74-
when(recipe.getDescription()).thenReturn(recipeDescription);
75-
when(recipe.getAutomationInfo()).thenReturn(RecipeAutomation.AUTOMATED);
76-
77-
AttributedStringBuilder builder = new AttributedStringBuilder();
78-
builder.style(AttributedStyle.DEFAULT);
79-
builder.append(" - ");
80-
builder.style(AttributedStyle.DEFAULT.italicDefault().boldDefault().foreground(Colors.rgbColor("yellow")));
81-
builder.append(recipe.getName());
82-
builder.style(AttributedStyle.DEFAULT);
83-
builder.append(" [" + RecipeRenderer.AUTOMATED_EMOJI + "]");
84-
builder.append("\n -> " + recipe.getDescription());
85-
builder.append("\n");
86-
87-
AttributedStringBuilder builder2 = new AttributedStringBuilder();
88-
assertThat(sut.buildRecipePresentation(builder2, recipe).toAttributedString())
89-
.isEqualTo(builder.toAttributedString());
90-
}
91-
92-
@Test
93-
void shouldRenderRecipeWithPartiallyAutomatedEmoji() {
94-
95-
Recipe recipe = mock(Recipe.class);
96-
String recipeName = "recipe-1";
97-
String recipeDescription = "the description";
98-
99-
when(recipe.getName()).thenReturn(recipeName);
100-
when(recipe.getDescription()).thenReturn(recipeDescription);
101-
when(recipe.getAutomationInfo()).thenReturn(RecipeAutomation.PARTIALLY_AUTOMATED);
102-
103-
AttributedStringBuilder builder = new AttributedStringBuilder();
104-
builder.style(AttributedStyle.DEFAULT);
105-
builder.append(" - ");
106-
builder.style(AttributedStyle.DEFAULT.italicDefault().boldDefault().foreground(Colors.rgbColor("yellow")));
107-
builder.append(recipe.getName());
108-
builder.style(AttributedStyle.DEFAULT);
109-
builder.append(" [" + RecipeRenderer.MANUAL_EMOJI + " " + RecipeRenderer.AUTOMATED_EMOJI + "]");
110-
builder.append("\n -> " + recipe.getDescription());
111-
builder.append("\n");
112-
113-
AttributedStringBuilder builder2 = new AttributedStringBuilder();
114-
assertThat(sut.buildRecipePresentation(builder2, recipe).toAttributedString())
115-
.isEqualTo(builder.toAttributedString());
58+
AttributedString attributedString = sut.buildRecipePresentation(builder2, recipe).toAttributedString();
59+
AttributedString expectedAttributedString = builder.toAttributedString();
60+
assertThat(attributedString)
61+
.as(attributedString + " " + expectedAttributedString)
62+
.isEqualTo(expectedAttributedString);
11663
}
11764

11865
@Test
@@ -128,14 +75,13 @@ void shouldRenderListOfRecipesWhenNotEmpty() {
12875

12976
AttributedStringBuilder builder = new AttributedStringBuilder();
13077

131-
when(sut.renderEmojiMapping()).thenReturn(emojiMapping);
13278
sut.buildRecipePresentation(builder, recipe1);
13379
sut.buildRecipePresentation(builder, recipe2);
13480

13581

13682
AttributedString attributedString = sut.renderRecipesList("", title, List.of(recipe1, recipe2));
13783

138-
assertThat(attributedString.toString()).contains(emojiMapping.toString(), title, recipe1Name, recipe2Name);
84+
assertThat(attributedString.toString()).contains(title, recipe1Name, recipe2Name);
13985
}
14086

14187
@Test

components/sbm-core/src/main/java/org/springframework/sbm/engine/context/ProjectContext.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ public ProjectResourceSet getProjectResources() {
6060
return projectResources;
6161
}
6262

63+
/**
64+
* @deprecated
65+
* Use {@link #getApplicationModules()} instead.
66+
* TODO: Make method private
67+
*/
68+
@Deprecated(forRemoval = false)
6369
public List<Module> getModules() {
6470
return search(new BuildFileProjectResourceFilter()).stream()
6571
.map(this::mapToModule)

0 commit comments

Comments
 (0)