@@ -45,6 +45,102 @@ public void shouldUploadTwelveFiles() throws Exception
4545 );
4646 }
4747
48+ @ Test
49+ public void shouldUploadOneFileWithLangTemplate () throws Exception
50+ {
51+ //given
52+ Configuration configuration = new Configuration ();
53+ configuration .setApiKey ("my-api-key" );
54+ configuration .setUploadPath ("./junit/download-test/values-{lang}/strings.xml" );
55+ configuration .setLanguageKey ("en" );
56+ configuration .setUploadFormat ("android" );
57+
58+ //when
59+ UploadCommand uploadCommand = new UploadCommand (client , configuration );
60+ uploadCommand .invoke ();
61+
62+ //then
63+ Mockito .verify (client , Mockito .times (1 )).uploadFile (
64+ Mockito .refEq (UploadRequest .UploadFileRequestBuilder .anUploadFileRequest ()
65+ .withPath (Path .of ("./junit/download-test/values-{lang}/strings.xml" ))
66+ .withFormat ("android" )
67+ .withLanguageKey ("en" )
68+ .withOptions (Collections .emptyList ())
69+ .build (),
70+ "path"
71+ )
72+ );
73+ }
74+
75+ @ Test
76+ public void shouldUploadOneFileWithOnlyTranslationKeys () throws Exception
77+ {
78+ //given
79+ Configuration configuration = new Configuration ();
80+ configuration .setApiKey ("my-api-key" );
81+ configuration .setUploadPath ("./junit/download-test/values-en/strings.xml" );
82+ configuration .setUploadFormat ("android" );
83+
84+ //when
85+ UploadCommand uploadCommand = new UploadCommand (client , configuration );
86+ uploadCommand .invoke ();
87+
88+ //then
89+ Mockito .verify (client , Mockito .times (1 )).uploadFile (
90+ Mockito .refEq (UploadRequest .UploadFileRequestBuilder .anUploadFileRequest ()
91+ .withPath (Path .of ("./junit/download-test/values-en/strings.xml" ))
92+ .withFormat ("android" )
93+ .withLanguageKey ("" )
94+ .withOptions (Collections .emptyList ())
95+ .build ()
96+ )
97+ );
98+ }
99+
100+ @ Test
101+ public void shouldSkipEmptyFile () throws Exception
102+ {
103+ //given
104+ Configuration configuration = new Configuration ();
105+ configuration .setApiKey ("my-api-key" );
106+ configuration .setUploadPath ("./junit/empty-test/strings.xml" );
107+ configuration .setUploadFormat ("android" );
108+
109+ //when
110+ UploadCommand uploadCommand = new UploadCommand (client , configuration );
111+ uploadCommand .invoke ();
112+
113+ //then
114+ Mockito .verifyNoInteractions (client );
115+ }
116+
117+ @ Test
118+ public void shouldUploadOneFile () throws Exception
119+ {
120+ //given
121+ Configuration configuration = new Configuration ();
122+ configuration .setApiKey ("my-api-key" );
123+ configuration .setUploadPath ("./junit/download-test/values-en/strings.xml" );
124+ configuration .setLanguageKey ("en" );
125+ configuration .setUploadFormat ("android" );
126+
127+ //when
128+ UploadCommand uploadCommand = new UploadCommand (client , configuration );
129+ uploadCommand .invoke ();
130+
131+ //then
132+ Mockito .verify (client , Mockito .times (1 )).uploadFile (
133+ Mockito .refEq (UploadRequest .UploadFileRequestBuilder .anUploadFileRequest ()
134+ .withPath (Path .of ("./junit/download-test/values-{lang}/strings.xml" ))
135+ .withFormat ("android" )
136+ .withLanguageKey ("en" )
137+ .withOptions (Collections .emptyList ())
138+ .build (),
139+ "path"
140+ )
141+ );
142+ }
143+
48144 @ Test
49145 public void shouldUploadZeroFiles () throws Exception
50146 {
0 commit comments