15
15
*/
16
16
package org .springframework .sbm .shell ;
17
17
18
- import org .springframework .sbm .engine .recipe .Recipe ;
19
- import org .springframework .sbm .engine .recipe .RecipeAutomation ;
20
18
import org .jline .utils .AttributedString ;
21
19
import org .jline .utils .AttributedStringBuilder ;
22
20
import org .jline .utils .AttributedStyle ;
23
21
import org .jline .utils .Colors ;
24
22
import org .junit .jupiter .api .Test ;
25
23
import org .junit .jupiter .api .extension .ExtendWith ;
26
24
import org .mockito .junit .jupiter .MockitoExtension ;
25
+ import org .springframework .sbm .engine .recipe .Recipe ;
27
26
28
27
import java .util .Collections ;
29
28
import java .util .List ;
@@ -37,82 +36,30 @@ class RecipeRendererTest {
37
36
RecipeRenderer sut = new RecipeRenderer ();
38
37
39
38
@ Test
40
- void shouldRenderRecipeWithManualEmoji () {
39
+ void shouldRenderRecipe () {
41
40
42
41
Recipe recipe = mock (Recipe .class );
43
42
String recipeName = "recipe-1" ;
44
43
String recipeDescription = "the description" ;
45
44
46
45
when (recipe .getName ()).thenReturn (recipeName );
47
46
when (recipe .getDescription ()).thenReturn (recipeDescription );
48
- when (recipe .getAutomationInfo ()).thenReturn (RecipeAutomation .MANUAL );
49
-
50
47
51
48
AttributedStringBuilder builder = new AttributedStringBuilder ();
52
49
builder .style (AttributedStyle .DEFAULT );
53
50
builder .append (" - " );
54
- builder .style (AttributedStyle .DEFAULT .italicDefault (). boldDefault ().foreground (Colors .rgbColor ("yellow" )));
51
+ builder .style (AttributedStyle .DEFAULT .boldDefault ().foreground (Colors .rgbColor ("yellow" )));
55
52
builder .append (recipe .getName ());
56
53
builder .style (AttributedStyle .DEFAULT );
57
- builder .append (" [" + RecipeRenderer .MANUAL_EMOJI + "]" );
58
54
builder .append ("\n -> " + recipe .getDescription ());
59
55
builder .append ("\n " );
60
56
61
57
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 );
116
63
}
117
64
118
65
@ Test
@@ -128,14 +75,13 @@ void shouldRenderListOfRecipesWhenNotEmpty() {
128
75
129
76
AttributedStringBuilder builder = new AttributedStringBuilder ();
130
77
131
- when (sut .renderEmojiMapping ()).thenReturn (emojiMapping );
132
78
sut .buildRecipePresentation (builder , recipe1 );
133
79
sut .buildRecipePresentation (builder , recipe2 );
134
80
135
81
136
82
AttributedString attributedString = sut .renderRecipesList ("" , title , List .of (recipe1 , recipe2 ));
137
83
138
- assertThat (attributedString .toString ()).contains (emojiMapping . toString (), title , recipe1Name , recipe2Name );
84
+ assertThat (attributedString .toString ()).contains (title , recipe1Name , recipe2Name );
139
85
}
140
86
141
87
@ Test
0 commit comments