File tree Expand file tree Collapse file tree
org.moreunit.mock.test/test/org/moreunit/mock/templates Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -173,6 +173,30 @@ public void should_return_urls_of_templates_that_are_already_defined_with_a_reas
173173 entry (existingDefinition2Url , "A template is already defined with this ID" ));
174174 }
175175
176+ @ Test
177+ public void should_log_error_when_template_already_defined () throws Exception
178+ {
179+ // given
180+ URL definitionUrl = URI .create ("file:/already.defined.url" ).toURL ();
181+ when (resourceLoader .findBundleResources (eq (TEMPLATE_DIRECTORY ), anyString ())).thenReturn (singleton (definitionUrl ));
182+ when (resourceLoader .findWorkspaceStateResources (anyString (), anyString ())).thenReturn (noResources );
183+
184+ TemplateAlreadyDefinedException exception = new TemplateAlreadyDefinedException ("templateId" );
185+ when (templateDefinitionReader .read (definitionUrl )).thenReturn (someTemplates );
186+ doThrow (exception ).when (templateStore ).store (someTemplates );
187+
188+ // when
189+ LoadingResult result = loader .loadTemplates ();
190+
191+ // then
192+ verify (logger ).error ("Could not load template " + definitionUrl , exception );
193+
194+ assertThat (result .invalidTemplatesFound ()).isTrue ();
195+ assertThat (result .invalidTemplates ()).hasSize (1 )
196+ .contains (entry (definitionUrl , "A template is already defined with this ID" ));
197+
198+ }
199+
176200 private MockingTemplates someTemplates ()
177201 {
178202 return new MockingTemplates (new ArrayList <Category >(), asList (new MockingTemplate ("template" )));
You can’t perform that action at this time.
0 commit comments