use of com.b2international.snowowl.eventbus.IEventBus in project snow-owl by b2ihealthcare.
the class EventBusHandlerRegistrationTest method test_RegisterHandler_NonNull_NonNull.
@Test
public void test_RegisterHandler_NonNull_NonNull() {
final IEventBus actual = bus.registerHandler(ADDRESS, noopHandler);
assertEquals(bus, actual);
}
use of com.b2international.snowowl.eventbus.IEventBus in project snow-owl by b2ihealthcare.
the class EventBusSendTest method test_Publish_NoHandlers.
@Test
public void test_Publish_NoHandlers() throws InterruptedException {
final IEventBus actual = bus.publish(ADDRESS, SEND_MESSAGE, null);
assertEquals(bus, actual);
}
use of com.b2international.snowowl.eventbus.IEventBus in project snow-owl by b2ihealthcare.
the class EventBusNet4jUtil method prepareContainer.
/**
* Prepares the given {@link IManagedContainer} to deliver message through {@link IEventBus} instances over the
* network.
*
* @param container
* @param gzip - to enable gzip compression on the protocol or not
* @param numberOfWorkers
*/
public static final void prepareContainer(IManagedContainer container, boolean gzip, int numberOfWorkers) {
container.registerFactory(new EventBusProtocol.ClientFactory());
container.registerFactory(new EventBusProtocol.ServerFactory());
container.registerFactory(new EventBus.Factory());
container.addPostProcessor(new EventBusProtocolInjector(numberOfWorkers));
if (gzip) {
container.addPostProcessor(new GZIPStreamWrapperInjector(EventBusConstants.PROTOCOL_NAME));
}
}
use of com.b2international.snowowl.eventbus.IEventBus in project snow-owl by b2ihealthcare.
the class SnomedContentRule method createCodeSystemIfNotExist.
private void createCodeSystemIfNotExist() {
final IEventBus eventBus = Services.bus();
final CodeSystems codeSystems = CodeSystemRequests.prepareSearchCodeSystem().setLimit(0).filterById(codeSystemId.getResourceId()).buildAsync().execute(eventBus).getSync();
if (codeSystems.getTotal() > 0) {
return;
}
final ResourceURI extensionOf = Optional.ofNullable(this.extensionOf).or(() -> {
return ResourceRequests.prepareSearchVersion().filterByResource(SNOMEDCT).sortBy(Sort.fieldDesc(VersionDocument.Fields.EFFECTIVE_TIME)).setLimit(1).buildAsync().execute(eventBus).getSync().first().map(Version::getVersionResourceURI);
}).orElse(null);
CodeSystemRequests.prepareNewCodeSystem().setId(codeSystemId.getResourceId()).setBranchPath(SNOMEDCT.equals(codeSystemId) ? Branch.MAIN_PATH : null).setUrl(SNOMEDCT.equals(codeSystemId) ? SnomedTerminologyComponentConstants.SNOMED_URI_SCT + "/" + Concepts.MODULE_SCT_CORE : SnomedTerminologyComponentConstants.SNOMED_URI_SCT + "/" + codeSystemId.getResourceId()).setDescription("description").setExtensionOf(extensionOf).setLanguage("ENG").setTitle(codeSystemId.getResourceId()).setOid("oid:" + codeSystemId).setOwner("https://b2i.sg").setToolingId(SnomedTerminologyComponentConstants.TOOLING_ID).setSettings(Map.of(SnomedTerminologyComponentConstants.CODESYSTEM_LANGUAGE_CONFIG_KEY, List.of(Map.of("languageTag", "en", "languageRefSetIds", Lists.newArrayList(Concepts.REFSET_LANGUAGE_TYPE_UK, Concepts.REFSET_LANGUAGE_TYPE_US))))).build(RestExtensions.USER, String.format("Create code system %s", codeSystemId)).execute(eventBus).getSync(1, TimeUnit.MINUTES);
}
use of com.b2international.snowowl.eventbus.IEventBus in project snow-owl by b2ihealthcare.
the class CommitInfoRequestTest method searchCommitOnSubBranch.
@Test
public void searchCommitOnSubBranch() {
// Search with no branch filter, to test security filter for user with limited resources
final String oid = UUID.randomUUID().toString();
final String shortName = "Resource7";
final String comment = "Code system for commit info 7";
final String branchName = "Test7";
final String commitComment = "Create Description 7";
final String term = "Test Description 7";
// Commit on resource branch
createCodeSystem(shortName, oid, comment);
createDescription(ResourceURI.of(CodeSystem.RESOURCE_TYPE, shortName), term, commitComment);
// Commit on version branch
final String branchPath = createBranch(String.format("%s/%s", BRANCH, shortName), branchName);
createDescription(ResourceURI.branch(CodeSystem.RESOURCE_TYPE, shortName, branchName), term, commitComment);
// Commit on deeper branch
final String newBranchName = String.format("%s/%s", branchName, branchName);
createBranch(branchPath, branchName);
createDescription(ResourceURI.branch(CodeSystem.RESOURCE_TYPE, shortName, newBranchName), term, commitComment);
final Permission userPermission = Permission.requireAll(Permission.OPERATION_BROWSE, String.format("%s*", shortName));
final List<Role> roles = List.of(new Role("Editor", List.of(userPermission)));
final String userName = "User7";
final User user = new User(userName, roles);
final IEventBus authorizedBus = new AuthorizedEventBus(bus, ImmutableMap.of(AuthorizedRequest.AUTHORIZATION_HEADER, Services.service(JWTGenerator.class).generate(user)));
// Search as user with permission only to access the resource and one sub branch
assertEquals(2, RepositoryRequests.commitInfos().prepareSearchCommitInfo().filterByComment(commitComment).build(REPOSITORY_ID).execute(authorizedBus).getSync().getTotal());
// Search as admin user with permission to access all
assertEquals(3, RepositoryRequests.commitInfos().prepareSearchCommitInfo().filterByComment(commitComment).build(REPOSITORY_ID).execute(bus).getSync().getTotal());
}
Aggregations