List of usage examples for java.util Collections singletonList
public static <T> List<T> singletonList(T o)
From source file:net.lightbody.bmp.proxy.jetty.http.handler.SetResponseHeadersHandler.java
/** Set a header override, every response handled will have this header set. * @param name The String name of the header. * @param value The String value of the header. *//*from w ww .ja v a2 s . c om*/ public void setHeaderValue(String name, String value) { _fields.put(name, Collections.singletonList(value)); }
From source file:de.hybris.platform.cronjob.jalo.PLA_12481_Test.java
@Test public void testSetForeignKeyMultipleTimes() { final CompositeCronJob cj = modelService.getSource(compCronJob); final CompositeEntryModel entryModel = createEntry(compCronJob, "foo"); final CompositeEntry entry = modelService.getSource(entryModel); Assert.assertEquals(cj, entry.getCompositeCronJob()); Assert.assertEquals(Collections.singletonList(entry), cj.getCompositeEntries()); Assert.assertEquals(Integer.valueOf(0), entry.getProperty(CompositeEntry.COMPOSITECRONJOBPOS)); for (int i = 0; i < 10; i++) { entry.setCompositeCronJob(cj);/* w w w .j a va 2s.c om*/ Assert.assertEquals(cj, entry.getCompositeCronJob()); Assert.assertEquals(Integer.valueOf(0), entry.getProperty(CompositeEntry.COMPOSITECRONJOBPOS)); } }
From source file:org.yamj.api.trakttv.model.SyncItems.java
public SyncItems ids(int id) { this.ids = Collections.singletonList(id); return this; }
From source file:tds.assessment.web.endpoints.AssessmentWindowControllerTest.java
@Test public void shouldFindListOfAssessmentWindows() { AssessmentWindow window = new AssessmentWindow.Builder().withAssessmentKey("assessment") .withWindowId("windowId").build(); when(mockAssessmentWindowService.findAssessmentWindows(isA(AssessmentWindowParameters.class))) .thenReturn(Collections.singletonList(window)); ResponseEntity<List<AssessmentWindow>> response = controller.findAssessmentWindows("SBAC_PT", "assessment", false, 25, 50, 75, 100, "wid:formKey"); ArgumentCaptor<AssessmentWindowParameters> assessmentWindowParametersArgumentCaptor = ArgumentCaptor .forClass(AssessmentWindowParameters.class); verify(mockAssessmentWindowService)/*from www . ja v a 2s .c o m*/ .findAssessmentWindows(assessmentWindowParametersArgumentCaptor.capture()); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(response.getBody()).containsExactly(window); AssessmentWindowParameters parameters = assessmentWindowParametersArgumentCaptor.getValue(); assertThat(parameters.getAssessmentId()).isEqualTo("assessment"); assertThat(parameters.getClientName()).isEqualTo("SBAC_PT"); assertThat(parameters.isGuestStudent()).isFalse(); assertThat(parameters.getShiftWindowStart()).isEqualTo(25); assertThat(parameters.getShiftWindowEnd()).isEqualTo(50); assertThat(parameters.getShiftFormStart()).isEqualTo(75); assertThat(parameters.getShiftFormEnd()).isEqualTo(100); assertThat(parameters.getFormList()).isEqualTo("wid:formKey"); }
From source file:org.geoserver.wps.GetCapabilities.java
public WPSCapabilitiesType run(GetCapabilitiesType request) throws WPSException { // do the version negotiation dance List<String> provided = Collections.singletonList("1.0.0"); List<String> accepted = null; if (request.getAcceptVersions() != null) accepted = request.getAcceptVersions().getVersion(); String version = RequestUtils.getVersionOws11(provided, accepted); if (!"1.0.0".equals(version)) { throw new WPSException("Could not understand version:" + version); }/* www. ja v a2 s . com*/ // TODO: add update sequence negotiation // encode the response Wps10Factory wpsf = Wps10Factory.eINSTANCE; Ows11Factory owsf = Ows11Factory.eINSTANCE; WPSCapabilitiesType caps = wpsf.createWPSCapabilitiesType(); caps.setVersion("1.0.0"); // TODO: make configurable caps.setLang("en"); // ServiceIdentification ServiceIdentificationType si = owsf.createServiceIdentificationType(); caps.setServiceIdentification(si); si.getTitle().add(Ows11Util.languageString(wps.getTitle())); si.getAbstract().add(Ows11Util.languageString(wps.getAbstract())); KeywordsType kw = Ows11Util.keywords(wps.keywordValues()); ; if (kw != null) { si.getKeywords().add(kw); } si.setServiceType(Ows11Util.code("WPS")); si.getServiceTypeVersion().add("1.0.0"); si.setFees(wps.getFees()); if (wps.getAccessConstraints() != null) { si.getAccessConstraints().add(wps.getAccessConstraints()); } // ServiceProvider ServiceProviderType sp = owsf.createServiceProviderType(); caps.setServiceProvider(sp); // TODO: set provder name from context SettingsInfo settings = wps.getGeoServer().getSettings(); if (settings.getContact().getContactOrganization() != null) { sp.setProviderName(settings.getContact().getContactOrganization()); } else { sp.setProviderName("GeoServer"); } sp.setProviderSite(owsf.createOnlineResourceType()); sp.getProviderSite().setHref(settings.getOnlineResource()); sp.setServiceContact(responsibleParty(settings, owsf)); // OperationsMetadata OperationsMetadataType om = owsf.createOperationsMetadataType(); caps.setOperationsMetadata(om); OperationType gco = owsf.createOperationType(); gco.setName("GetCapabilities"); gco.getDCP().add(Ows11Util.dcp("wps", request)); om.getOperation().add(gco); OperationType dpo = owsf.createOperationType(); dpo.setName("DescribeProcess"); dpo.getDCP().add(Ows11Util.dcp("wps", request)); om.getOperation().add(dpo); OperationType eo = owsf.createOperationType(); eo.setName("Execute"); eo.getDCP().add(Ows11Util.dcp("wps", request)); om.getOperation().add(eo); ProcessOfferingsType po = wpsf.createProcessOfferingsType(); caps.setProcessOfferings(po); // gather the process list for (ProcessFactory pf : GeoServerProcessors.getProcessFactories()) { for (Name name : pf.getNames()) { ProcessBriefType p = wpsf.createProcessBriefType(); p.setProcessVersion(pf.getVersion(name)); po.getProcess().add(p); p.setIdentifier(Ows11Util.code(name)); p.setTitle(Ows11Util.languageString(pf.getTitle(name))); p.setAbstract(Ows11Util.languageString(pf.getDescription(name))); } } // sort it ECollections.sort(po.getProcess(), new Comparator() { public int compare(Object o1, Object o2) { ProcessBriefType pb1 = (ProcessBriefType) o1; ProcessBriefType pb2 = (ProcessBriefType) o2; final String id1 = pb1.getIdentifier().getValue(); final String id2 = pb2.getIdentifier().getValue(); return id1.compareTo(id2); } }); LanguagesType1 languages = wpsf.createLanguagesType1(); caps.setLanguages(languages); DefaultType2 defaultLanguage = wpsf.createDefaultType2(); languages.setDefault(defaultLanguage); defaultLanguage.setLanguage("en-US"); LanguagesType supportedLanguages = wpsf.createLanguagesType(); languages.setSupported(supportedLanguages); supportedLanguages.getLanguage().add("en-US"); return caps; // Version detection and alternative invocation if being implemented. }
From source file:de.codecentric.boot.admin.discovery.ApplicationDiscoveryListenerTest.java
@Test public void test_ignore() { when(discovery.getServices()).thenReturn(Collections.singletonList("service")); when(discovery.getInstances("service")).thenReturn(Collections .singletonList((ServiceInstance) new DefaultServiceInstance("service", "localhost", 80, false))); listener.setIgnoredServices(Collections.singleton("service")); listener.onInstanceRegistered(new InstanceRegisteredEvent<>(new Object(), null)); assertEquals(0, registry.getApplications().size()); }
From source file:org.bozzo.ipplan.web.assembler.InfrastructureResourceAssemblerTest.java
@Test public void toResources_with_singleton_array_should_return_a_singleton_array() { Infrastructure infra = new Infrastructure(); infra.setId(1);//from w w w . j a va2s. c om infra.setDescription("Test description"); infra.setGroup("group"); List<InfrastructureResource> resources = this.assembler.toResources(Collections.singletonList(infra)); Assert.assertNotNull(resources); Assert.assertEquals(1, resources.size()); Assert.assertTrue(ResourceSupport.class.isAssignableFrom(resources.get(0).getClass())); }
From source file:org.openmrs.module.webservices.rest.web.MockModuleFactoryWrapper.java
@Override public List<Module> stopModuleAndGetDependent(Module module) { return Collections .singletonList(new Module("dependent", "atlas", "name", "author", "description", "version")); }
From source file:com.epam.cme.storefront.controllers.pages.AbstractLoginPageController.java
protected String getDefaultLoginPage(final AuthenticationException loginException, final HttpSession session, final Model model) throws CMSItemNotFoundException { final LoginForm loginForm = new LoginForm(); model.addAttribute(loginForm);// w ww. ja v a2s. c o m model.addAttribute(new RegisterForm()); final String username = (String) session.getAttribute(SPRING_SECURITY_LAST_USERNAME); if (username != null) { session.removeAttribute(SPRING_SECURITY_LAST_USERNAME); } loginForm.setJ_username(username); storeCmsPageInModel(model, getCmsPage()); setUpMetaDataForContentPage(model, (ContentPageModel) getCmsPage()); model.addAttribute("metaRobots", "index,no-follow"); final Breadcrumb loginBreadcrumbEntry = new Breadcrumb("#", getMessageSource().getMessage("header.link.login", null, getI18nService().getCurrentLocale()), null); model.addAttribute("breadcrumbs", Collections.singletonList(loginBreadcrumbEntry)); if (loginException instanceof BadCredentialsException) { GlobalMessages.addErrorMessage(model, "login.error.account.not.found.title"); } else if (loginException instanceof LockedException) { GlobalMessages.addErrorMessage(model, "login.error.user.blocked.title"); } return getView(); }