void onResourceUpdated(@Observes ResourceUpdatedEvent res) { if (lockTarget != null && res.getPath().equals(lockTarget.getPath())) { if (!res.getSessionInfo().getIdentity().equals(user)) { reload(); } releaseLock(); } }
void onResourceUpdated(@Observes final ResourceUpdatedEvent updatedEvent) { if (path != null && path.equals(updatedEvent.getPath())) { if (sessionInfo.getId().equals(updatedEvent.getSessionInfo().getId())) { executeUpdateCommands(); } else { executeConcurrentUpdateCommand( updatedEvent.getPath(), updatedEvent.getSessionInfo().getId(), updatedEvent.getSessionInfo().getIdentity()); } } }
@Test public void doNotRefreshWhenAnotherUserMakesThePomXMLFileContentChange() throws Exception { final ResourceUpdatedEvent resourceUpdatedEvent = mock(ResourceUpdatedEvent.class); final SessionInfo sessionInfo = mock(SessionInfo.class); when(resourceUpdatedEvent.getSessionInfo()).thenReturn(sessionInfo); when(sessionInfo.getIdentity()).thenReturn(mock(User.class)); when(resourceUpdatedEvent.getPath()).thenReturn(mock(Path.class)); reset(view); presenter.onResourceUpdated(resourceUpdatedEvent); verify(view, never()).setPOM(any(POM.class)); }
@Test public void refreshWhenPomXMLFileContentChanges() throws Exception { final ResourceUpdatedEvent resourceUpdatedEvent = mock(ResourceUpdatedEvent.class); final SessionInfo sessionInfo = mock(SessionInfo.class); when(resourceUpdatedEvent.getSessionInfo()).thenReturn(sessionInfo); when(sessionInfo.getIdentity()).thenReturn(user); when(resourceUpdatedEvent.getPath()).thenReturn(observablePathToPomXML); reset(view); presenter.onResourceUpdated(resourceUpdatedEvent); verify(view).setPOM(any(POM.class)); }