use of org.uberfire.workbench.events.ResourceUpdatedEvent in project kie-wb-common by kiegroup.
the class ModuleRepositoriesSynchronizerTest method testAddAndRemoveModuleRepository.
@Test
public void testAddAndRemoveModuleRepository() {
final ResourceUpdatedEvent event = new ResourceUpdatedEvent(pomPath, "", sessionInfo);
final Set<ModuleRepositories.ModuleRepository> repositories = new HashSet<ModuleRepositories.ModuleRepository>() {
{
add(new ModuleRepositories.ModuleRepository(true, new MavenRepositoryMetadata("local-id", "local-url", MavenRepositorySource.LOCAL)));
}
};
final ModuleRepositories moduleRepositories = new ModuleRepositories(repositories);
when(moduleRepositoriesService.load(moduleRepositoriesPath)).thenReturn(moduleRepositories);
when(repositoryResolver.getRemoteRepositoriesMetaData(module)).thenReturn(new HashSet<MavenRepositoryMetadata>() {
{
add(new MavenRepositoryMetadata("remote-id", "remote-url", MavenRepositorySource.PROJECT));
}
});
synchronizer.onResourceUpdated(event);
final ArgumentCaptor<ModuleRepositories> moduleRepositoriesArgumentCaptor = ArgumentCaptor.forClass(ModuleRepositories.class);
verify(moduleRepositoriesService, times(1)).save(eq(moduleRepositoriesPath), moduleRepositoriesArgumentCaptor.capture(), any(String.class));
final ModuleRepositories saved = moduleRepositoriesArgumentCaptor.getValue();
assertNotNull(saved);
assertEquals(1, saved.getRepositories().size());
final ModuleRepositories.ModuleRepository repository = saved.getRepositories().iterator().next();
assertTrue(repository.isIncluded());
assertEquals("remote-id", repository.getMetadata().getId());
assertEquals("remote-url", repository.getMetadata().getUrl());
assertEquals(MavenRepositorySource.PROJECT, repository.getMetadata().getSource());
}
use of org.uberfire.workbench.events.ResourceUpdatedEvent in project kie-wb-common by kiegroup.
the class ResourceUpdatedEventAdapter method toSocial.
@Override
public SocialActivitiesEvent toSocial(Object object) {
ResourceUpdatedEvent event = (ResourceUpdatedEvent) object;
SocialUser socialUser = socialUserRepositoryAPI.findSocialUser(event.getSessionInfo().getIdentity().getIdentifier());
String additionalInfo = "Edited";
String description = getCommitDescription(event);
return new SocialActivitiesEvent(socialUser, HomePageTypes.RESOURCE_UPDATE_EVENT.name(), new Date()).withLink(event.getPath().getFileName(), event.getPath().toURI()).withAdicionalInfo(additionalInfo).withDescription(description);
}
use of org.uberfire.workbench.events.ResourceUpdatedEvent in project kie-wb-common by kiegroup.
the class ResourceUpdatedEventAdapter method isASystemEvent.
private boolean isASystemEvent(Object _event) {
ResourceUpdatedEvent event = (ResourceUpdatedEvent) _event;
final String user = event.getSessionInfo().getIdentity().getIdentifier();
if (user.equalsIgnoreCase("system") || user.equalsIgnoreCase("<system>")) {
return true;
}
return false;
}
use of org.uberfire.workbench.events.ResourceUpdatedEvent in project kie-wb-common by kiegroup.
the class ModuleRepositoriesSynchronizerTest method testAddModuleRepository.
@Test
public void testAddModuleRepository() {
final ResourceUpdatedEvent event = new ResourceUpdatedEvent(pomPath, "", sessionInfo);
final ModuleRepositories moduleRepositories = new ModuleRepositories();
when(moduleRepositoriesService.load(moduleRepositoriesPath)).thenReturn(moduleRepositories);
when(repositoryResolver.getRemoteRepositoriesMetaData(module)).thenReturn(new HashSet<MavenRepositoryMetadata>() {
{
add(new MavenRepositoryMetadata("local-id", "local-url", MavenRepositorySource.LOCAL));
}
});
synchronizer.onResourceUpdated(event);
final ArgumentCaptor<ModuleRepositories> moduleRepositoriesArgumentCaptor = ArgumentCaptor.forClass(ModuleRepositories.class);
verify(moduleRepositoriesService, times(1)).save(eq(moduleRepositoriesPath), moduleRepositoriesArgumentCaptor.capture(), any(String.class));
final ModuleRepositories saved = moduleRepositoriesArgumentCaptor.getValue();
assertNotNull(saved);
assertEquals(1, saved.getRepositories().size());
final ModuleRepositories.ModuleRepository repository = saved.getRepositories().iterator().next();
assertTrue(repository.isIncluded());
assertEquals("local-id", repository.getMetadata().getId());
assertEquals("local-url", repository.getMetadata().getUrl());
assertEquals(MavenRepositorySource.LOCAL, repository.getMetadata().getSource());
}
use of org.uberfire.workbench.events.ResourceUpdatedEvent in project kie-wb-common by kiegroup.
the class ModuleRepositoriesSynchronizerTest method testRemoveModuleRepository.
@Test
public void testRemoveModuleRepository() {
final ResourceUpdatedEvent event = new ResourceUpdatedEvent(pomPath, "", sessionInfo);
final Set<ModuleRepositories.ModuleRepository> repositories = new HashSet<ModuleRepositories.ModuleRepository>() {
{
add(new ModuleRepositories.ModuleRepository(true, new MavenRepositoryMetadata("local-id", "local-url", MavenRepositorySource.LOCAL)));
}
};
final ModuleRepositories moduleRepositories = new ModuleRepositories(repositories);
when(moduleRepositoriesService.load(moduleRepositoriesPath)).thenReturn(moduleRepositories);
synchronizer.onResourceUpdated(event);
final ArgumentCaptor<ModuleRepositories> moduleRepositoriesArgumentCaptor = ArgumentCaptor.forClass(ModuleRepositories.class);
verify(moduleRepositoriesService, times(1)).save(eq(moduleRepositoriesPath), moduleRepositoriesArgumentCaptor.capture(), any(String.class));
final ModuleRepositories saved = moduleRepositoriesArgumentCaptor.getValue();
assertNotNull(saved);
assertEquals(0, saved.getRepositories().size());
}
Aggregations