@Test public void whenProjectSubModulesEdited_UpdateModuleEventIsFired() throws Exception { final Path path = testFileSystem.createTempFile("testproject/pom.xml"); doReturn(true).when(ioService).exists(any()); final POM pom = new POM("newName", "desctiption", "url", new GAV()); pom.setPackaging("pom"); final ArrayList<String> modules = new ArrayList<>(); modules.add("module1"); modules.add("module2"); pom.setModules(modules); service.save(path, pom, mock(Metadata.class), "", true); verify(moduleUpdatedEvent, times(3)).fire(any()); } }
@Test public void whenProjectSavedWithoutChanges_ModuleUpdatedEventNotFired() throws Exception { final Path path = testFileSystem.createTempFile("testproject/pom.xml"); POM originalPOM = new POM("mymodule", "desctiption", "url", new GAV()); service.save(path, originalPOM, mock(Metadata.class), ""); verify(ioService).startBatch(any(), any()); verify(ioService).write(pathArgumentCaptor.capture(), anyString(), anyMap()); verify(ioService).endBatch(); verify(moduleUpdatedEvent, never()).fire(any()); assertTrue(path.toURI().endsWith(pathArgumentCaptor.getValue().toString())); }
@Test public void whenProjectRenamed_ModuleUpdatedEventIsFired() throws Exception { final Path path = testFileSystem.createTempFile("testproject/pom.xml"); service.save(path, new POM("newName", "desctiption", "url", new GAV()), mock(Metadata.class), ""); verify(moduleUpdatedEvent).fire(any()); } }
@Test public void whenProjectSavedWithoutChanges_ModuleUpdatedEventNotFired() throws Exception { final Path path = testFileSystem.createTempFile("testproject/pom.xml"); POM originalPOM = new POM("mymodule", "desctiption", "url", new GAV()); service.save(path, originalPOM, mock(Metadata.class), ""); verify(ioService).startBatch(any(), any()); verify(ioService).write(pathArgumentCaptor.capture(), anyString(), anyMap()); verify(ioService).endBatch(); verify(moduleUpdatedEvent, never()).fire(any()); assertTrue(path.toURI().endsWith(pathArgumentCaptor.getValue().toString())); }
@Test public void whenProjectRenamed_ModuleUpdatedEventIsFired() throws Exception { final Path path = testFileSystem.createTempFile("testproject/pom.xml"); service.save(path, new POM("newName", "desctiption", "url", new GAV()), mock(Metadata.class), ""); verify(moduleUpdatedEvent).fire(any()); } }
@Test public void whenProjectSubModulesEdited_UpdateModuleEventIsFired() throws Exception { final Path path = testFileSystem.createTempFile("testproject/pom.xml"); doReturn(true).when(ioService).exists(any()); final POM pom = new POM("newName", "desctiption", "url", new GAV()); pom.setPackaging("pom"); final ArrayList<String> modules = new ArrayList<>(); modules.add("module1"); modules.add("module2"); pom.setModules(modules); service.save(path, pom, mock(Metadata.class), "", true); verify(moduleUpdatedEvent, times(3)).fire(any()); } }
@Test public void testSave() throws Exception { final Path path = testFileSystem.createTempFile( "whitelist" ); final WhiteList whiteList = new WhiteList(); whiteList.add( "org.drools" );
@Before public void setUp() throws Exception { testFileSystem = new TestFileSystem(); saver = new ProjectScreenModelSaver(pomService, kModuleService, importsService, repositoriesService, whiteListService, ioService, moduleService, repositoryResolver, commentedOptionFactory, pomModelCache); pathToPom = testFileSystem.createTempFile("testproject/pom.xml"); }
@Test public void testWorkingURI() throws Exception { final Path tempFile = testFileSystem.createTempFile( "text.txt" ); final InboxEntry entry = new InboxEntry( tempFile.toURI(), "note", "userFrom" ); assertEquals( repository, inbox.getInboxEntryRepository( entry ) ); }
@Test public void testFileRemoved() throws Exception { final Path tempFile = testFileSystem.createTempFile( "text.txt" ); testFileSystem.deleteFile( tempFile ); final InboxEntry entry = new InboxEntry( tempFile.toURI(), "note", "userFrom" ); assertEquals( repository, inbox.getInboxEntryRepository( entry ) ); }