Skip to content

Commit

Permalink
Add the default FILECOMMENT template to the preference initialization.
Browse files Browse the repository at this point in the history
- By re-setting FILECOMMENT for every initialization, we ensure the
  underlying code template store starts with the default value
- This should fix UnresolvedTypesQuickFixTest, which may fail depending
  on test order and is sensitive to the state of the code template store

Signed-off-by: Roland Grunberg <[email protected]>
  • Loading branch information
rgrunber committed Apr 14, 2022
1 parent 0337193 commit 8bbc576
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public static void initialize() {
templates.put(CodeTemplatePreferences.CODETEMPLATE_CATCHBODY, CodeGenerationTemplate.CATCHBODY.createTemplate());
templates.put(CodeTemplatePreferences.CODETEMPLATE_METHODBODY, CodeGenerationTemplate.METHODBODY.createTemplate());
templates.put(CodeTemplatePreferences.CODETEMPLATE_NEWTYPE, CodeGenerationTemplate.NEWTYPE.createTemplate());
templates.put(CodeTemplatePreferences.CODETEMPLATE_FILECOMMENT, CodeGenerationTemplate.FILECOMMENT.createTemplate());
reloadTemplateStore();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.never;
Expand Down Expand Up @@ -136,7 +135,8 @@ public void testUpdateFileHeaderTemplate() {
preferenceManager.initialize();

Template template = JavaManipulation.getCodeTemplateStore().findTemplateById(CodeTemplateContextType.FILECOMMENT_ID);
assertNull(template);
assertNotNull(template);
assertEquals("", template.getPattern());

Preferences preferences = new Preferences();
preferences.setFileHeaderTemplate(Arrays.asList("/** */"));
Expand Down

0 comments on commit 8bbc576

Please sign in to comment.