List of usage examples for java.util Collections singleton
public static <T> Set<T> singleton(T o)
From source file:io.gravitee.gateway.services.sync.SyncManagerTest.java
@Test public void test_newApi() throws Exception { io.gravitee.repository.management.model.Api api = new RepositoryApiBuilder().id("api-test") .updatedAt(new Date()).definition("test").build(); final Api mockApi = mockApi(api); final Event mockEvent = mockEvent(api, EventType.PUBLISH_API); when(eventRepository.search(new EventCriteria.Builder() .types(EventType.PUBLISH_API, EventType.UNPUBLISH_API, EventType.START_API, EventType.STOP_API) .build())).thenReturn(Collections.singletonList(mockEvent)); when(apiRepository.findAll()).thenReturn(Collections.singleton(api)); syncManager.refresh();/*from w w w.j av a 2 s . co m*/ verify(apiManager).deploy(mockApi); verify(apiManager, never()).update(any(Api.class)); verify(apiManager, never()).undeploy(any(String.class)); }
From source file:io.gravitee.gateway.repository.plugins.RepositoryPluginHandler.java
@Override public void handle(Plugin plugin) { try {//from w w w. ja va 2s . c o m ClassLoader classloader = pluginClassLoaderFactory.getOrCreateClassLoader(plugin, this.getClass().getClassLoader()); final Class<?> repositoryClass = classloader.loadClass(plugin.clazz()); LOGGER.info("Register a new repository plugin: {} [{}]", plugin.id(), plugin.clazz()); Assert.isAssignable(Repository.class, repositoryClass); Repository repository = createInstance((Class<Repository>) repositoryClass); for (Scope scope : repository.scopes()) { if (!repositories.containsKey(scope)) { String requiredRepositoryType = repositoryTypeByScope.get(scope); // Load only repository plugin for a given scope (provided in the configuration) if (repository.type().equalsIgnoreCase(requiredRepositoryType)) { LOGGER.info("Repository [{}] loaded by {}", scope, repository.type()); // Not yet loaded, let's mount the repository in application context try { ApplicationContext repoApplicationContext = pluginContextFactory .create(new AnnotationBasedPluginContextConfigurer(plugin) { @Override public Set<Class<?>> configurations() { return Collections.singleton(repository.configuration(scope)); } }); registerRepositoryDefinitions(repository, repoApplicationContext); repositories.put(scope, repository); } catch (Exception iae) { LOGGER.error("Unexpected error while creating context for repository instance", iae); pluginContextFactory.remove(plugin); } } else { LOGGER.debug("Scoped repository [{}] must be loaded by {}. Skipping registration", scope, requiredRepositoryType); } } else { LOGGER.warn("Repository scope {} already loaded by {}", scope, repositories.get(scope)); } } } catch (Exception iae) { LOGGER.error("Unexpected error while create repository instance", iae); } }
From source file:com.hp.alm.ali.idea.action.BlockItemAction.java
@Override public void setSelected(AnActionEvent event, boolean selected) { Project project = getEventProject(event); if (project != null) { Entity entity = EntityAction.getEntity(event); boolean isBlocked = isBlockedEntity(entity); Entity backlogItem = new Entity("release-backlog-item", Integer.valueOf(entity.getPropertyValue("release-backlog-item.id"))); if (!selected && isBlocked) { backlogItem.setProperty("blocked", null); } else if (selected && !isBlocked) { String reason = Messages.showInputDialog(project, "Provide the reason why the item is blocked", "Blocking Reason", null); if (reason != null) { backlogItem.setProperty("blocked", reason); } else { return; }//from w w w .j a v a 2 s.c o m } else { return; } EntityService entityService = project.getComponent(EntityService.class); entityService.updateEntity(backlogItem, Collections.singleton("blocked"), false); } }
From source file:eu.mihosoft.vrl.fxscad.MainController.java
/** * Initializes the controller class.//from ww w . jav a2 s. c om * * @param url * @param rb */ @Override public void initialize(URL url, ResourceBundle rb) { // codeArea.textProperty().addListener((ov, oldText, newText) -> { Matcher matcher = KEYWORD_PATTERN.matcher(newText); int lastKwEnd = 0; StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>(); while (matcher.find()) { spansBuilder.add(Collections.emptyList(), matcher.start() - lastKwEnd); spansBuilder.add(Collections.singleton("keyword"), matcher.end() - matcher.start()); lastKwEnd = matcher.end(); } spansBuilder.add(Collections.emptyList(), newText.length() - lastKwEnd); codeArea.setStyleSpans(0, spansBuilder.create()); }); EventStream<Change<String>> textEvents = EventStreams.changesOf(codeArea.textProperty()); textEvents.reduceSuccessions((a, b) -> b, Duration.ofMillis(500)).subscribe(code -> { if (autoCompile) { compile(code.getNewValue()); } }); codeArea.replaceText("CSG cube = new Cube(2).toCSG()\n" + "CSG sphere = new Sphere(1.25).toCSG()\n" + "\n" + "cube.difference(sphere)"); editorContainer.setContent(codeArea); subScene = new SubScene(viewGroup, 100, 100, true, SceneAntialiasing.BALANCED); subScene.widthProperty().bind(viewContainer.widthProperty()); subScene.heightProperty().bind(viewContainer.heightProperty()); PerspectiveCamera subSceneCamera = new PerspectiveCamera(false); subScene.setCamera(subSceneCamera); viewContainer.getChildren().add(subScene); }
From source file:webFramework.MappingJackson2PrettyJsonView.java
/** * {@inheritDoc} */ @Override public void setModelKey(String modelKey) { this.modelKeys = Collections.singleton(modelKey); }
From source file:org.obiba.mica.config.WebConfiguration.java
@Bean EmbeddedServletContainerCustomizer containerCustomizer() throws Exception { return (ConfigurableEmbeddedServletContainer container) -> { JettyEmbeddedServletContainerFactory jetty = (JettyEmbeddedServletContainerFactory) container; jetty.setServerCustomizers(Collections.singleton(this)); };/*from ww w.j a v a 2 s .co m*/ }
From source file:org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties.java
@Override protected Set<PropertyPathConnector> getAllSchemaPropertiesConnectors(boolean isOutputConnection) { if (isOutputConnection) { return Collections.singleton(MAIN_CONNECTOR); } else {// w w w . j a v a 2 s.c o m return Collections.EMPTY_SET; } }
From source file:com.mauersu.util.redis.DefaultSetOperations.java
public Long intersectAndStore(K key, K otherKey, K destKey) { return intersectAndStore(key, Collections.singleton(otherKey), destKey); }
From source file:com.hp.autonomy.frontend.configuration.server.ServerConfigTest.java
@Test public void testValidate() { final ProductType productType = ProductType.SERVICECOORDINATOR; final GetVersionResponseData getVersionResponseData = mockGetVersionResponse(productType.name()); when(aciService.executeAction(argThat(new IsAciServerDetails("example.com", 6666)), argThat(SetContainingItems.isSetWithItems(aciParameter("action", "GetVersion"))), any())) .thenReturn(getVersionResponseData); when(aciService.executeAction(argThat(new IsAciServerDetails("example.com", 6666)), argThat(SetContainingItems.isSetWithItems(aciParameter("action", "GetChildren"))), any())) .thenReturn(mockGetChildrenResponse(6666, 6668)); when(aciService.executeAction(argThat(new IsAciServerDetails("example.com", 6668)), argThat(SetContainingItems.isSetWithItems(aciParameter("action", "GetStatus"))), any())) .thenReturn(true);//from www. ja v a 2 s . c o m final ServerConfig serverConfig = ServerConfig.builder().host("example.com").port(6666) .productType(Collections.singleton(productType)).build(); assertThat(serverConfig.validate(aciService, null, processorFactory), is(valid())); }
From source file:org.openmrs.module.kenyaemr.page.controller.chart.ChartViewPatientPageController.java
public void controller(@RequestParam(required = false, value = "visitId") Visit visit, @RequestParam(required = false, value = "formUuid") String formUuid, @RequestParam(required = false, value = "programId") Program program, @RequestParam(required = false, value = "section") String section, PageModel model, UiUtils ui, Session session, PageRequest pageRequest, @SpringBean KenyaUiUtils kenyaUi, @SpringBean FormManager formManager, @SpringBean ProgramManager programManager) { if ("".equals(formUuid)) { formUuid = null;//from ww w . j a va 2s . c o m } Patient patient = (Patient) model.getAttribute(EmrWebConstants.MODEL_ATTR_CURRENT_PATIENT); recentlyViewed(patient, session); AppDescriptor thisApp = kenyaUi.getCurrentApp(pageRequest); List<FormDescriptor> oneTimeFormDescriptors = formManager.getCommonFormsForPatient(thisApp, patient); List<SimpleObject> oneTimeForms = new ArrayList<SimpleObject>(); for (FormDescriptor formDescriptor : oneTimeFormDescriptors) { Form form = formDescriptor.getTarget(); oneTimeForms.add(ui.simplifyObject(form)); } model.addAttribute("oneTimeForms", oneTimeForms); Collection<ProgramDescriptor> progams = programManager.getPatientPrograms(patient); model.addAttribute("programs", progams); model.addAttribute("programSummaries", programSummaries(patient, progams, programManager, kenyaUi)); model.addAttribute("visits", Context.getVisitService().getVisitsByPatient(patient)); model.addAttribute("visitsCount", Context.getVisitService().getVisitsByPatient(patient).size()); Form form = null; String selection = null; if (visit != null) { selection = "visit-" + visit.getVisitId(); } else if (formUuid != null) { selection = "form-" + formUuid; form = Context.getFormService().getFormByUuid(formUuid); List<Encounter> encounters = Context.getEncounterService().getEncounters(patient, null, null, null, Collections.singleton(form), null, null, null, null, false); Encounter encounter = encounters.size() > 0 ? encounters.get(0) : null; model.addAttribute("encounter", encounter); } else if (program != null) { selection = "program-" + program.getProgramId(); } else { if (StringUtils.isEmpty(section)) { section = "overview"; } selection = "section-" + section; } model.addAttribute("form", form); model.addAttribute("visit", visit); model.addAttribute("program", program); model.addAttribute("section", section); model.addAttribute("selection", selection); }