List of usage examples for java.util Collections singletonList
public static <T> List<T> singletonList(T o)
From source file:io.pivotal.strepsirrhini.chaosloris.web.ScheduleResourceAssemblerTest.java
@Test public void toResource() { Application application = new Application(UUID.randomUUID()); application.setId(-1L);//from w ww . ja v a 2s. c o m Schedule schedule = new Schedule("0 0 * * * *", "hourly"); schedule.setId(-2L); Chaos chaos = new Chaos(application, 0.2, schedule); chaos.setId(-3L); when(this.chaosRepository.findBySchedule(schedule)).thenReturn(Collections.singletonList(chaos)); ScheduleResourceAssembler.ScheduleResource resource = this.resourceAssembler.toResource(schedule); assertThat(resource.getContent()).isSameAs(schedule); assertThat(resource.getLinks()).hasSize(2); assertThat(resource.getLink("chaos")).isNotNull(); }
From source file:org.training.storefront.controllers.pages.AbstractLoginPageController.java
protected String getDefaultLoginPage(final boolean loginError, final HttpSession session, final Model model) throws CMSItemNotFoundException { final LoginForm loginForm = new LoginForm(); model.addAttribute(loginForm);/*w ww . j a va 2s . co m*/ model.addAttribute(new RegisterForm()); model.addAttribute(new GuestForm()); 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 (loginError) { model.addAttribute("loginError", Boolean.valueOf(loginError)); GlobalMessages.addErrorMessage(model, "login.error.account.not.found.title"); } return getView(); }
From source file:com.hp.autonomy.frontend.find.core.parametricfields.AbstractParametricValuesControllerTest.java
@Test public void getDependentParametricValues() throws E { parametricValuesController.getDependentParametricValues(Collections.singletonList("SomeParametricField"), "Some query text", null, Collections.<S>emptyList(), null, null, 0, null); verify(parametricValuesService).getDependentParametricValues(Matchers.<R>any()); }
From source file:io.pivotal.strepsirrhini.chaosloris.web.ApplicationResourceAssemblerTest.java
@Test public void toResource() { Application application = new Application(UUID.randomUUID()); application.setId(-1L);/*from w w w . j a v a 2 s. c om*/ Schedule schedule = new Schedule("0 0 * * * *", "hourly"); schedule.setId(-2L); Chaos chaos = new Chaos(application, 0.2, schedule); chaos.setId(-3L); when(this.chaosRepository.findByApplication(application)).thenReturn(Collections.singletonList(chaos)); ApplicationResourceAssembler.ApplicationResource resource = this.resourceAssembler.toResource(application); assertThat(resource.getContent()).isSameAs(application); assertThat(resource.getLinks()).hasSize(2); assertThat(resource.getLink("chaos")).isNotNull(); }
From source file:org.surfnet.oaaas.resource.resourceserver.ResourceOwnerResource.java
/** * Get all existing resource owners for the provided credentials (== owner) or in case of an adminPrincipal we return all resource servers. *///from ww w . j ava2 s . com @GET public Response getAll(@Context HttpServletRequest request) { Response validateScopeResponse = validateScope(request, Collections.singletonList(AbstractResource.SCOPE_READ)); if (validateScopeResponse != null) { return validateScopeResponse; } List<ResourceOwner> resourceOwners = getAllResourceOwners(request); return Response.ok(resourceOwners).build(); }
From source file:org.traccar.api.AsyncSocket.java
@Override public void onUpdateDevice(Device device) { Map<String, Collection<?>> data = new HashMap<>(); data.put(KEY_DEVICES, Collections.singletonList(device)); sendData(data);//from ww w .j a v a2s . c o m }
From source file:com.hp.autonomy.aci.content.identifier.stateid.StateIdsBuilder.java
/** * Creates a {@code StateIdsBuilder} containing the specified state token and range. * * @param stateToken The state token//from w ww .ja va2 s . c o m * @param range The index range */ public StateIdsBuilder(final String stateToken, final StateRange range) { doAppend(Collections.singletonList(new StateId(stateToken, range))); }
From source file:com.yahoo.elide.core.exceptions.HttpStatusException.java
public Pair<Integer, JsonNode> getVerboseErrorResponse() { Map<String, List<String>> errors = Collections.singletonMap("errors", Collections.singletonList(getVerboseMessage())); return buildResponse(errors); }
From source file:com.arpnetworking.tsdcore.sinks.ConsoleSinkTest.java
@Test public void testRecordProcessedAggregateData() { final AggregatedData datum = TestBeanFactory.createAggregatedData(); final List<AggregatedData> data = Collections.singletonList(datum); final Sink consoleSink = new ConsoleSink(_consoleSinkBuilder, _outputStream); consoleSink.recordAggregateData(data); final String output = _byteArrayStream.toString(); Assert.assertThat(output, Matchers.containsString(datum.getHost())); Assert.assertThat(output, Matchers.containsString(datum.getFQDSN().getService())); Assert.assertThat(output, Matchers.containsString(datum.getFQDSN().getMetric())); Assert.assertThat(output, Matchers.containsString(datum.getPeriodStart().toString())); Assert.assertThat(output, Matchers.containsString(datum.getPeriod().toString())); Assert.assertThat(output, Matchers.containsString(datum.getFQDSN().getStatistic().getName())); }
From source file:ch.cyberduck.core.sds.SDSMoveFeature.java
@Override public Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback) throws BackgroundException { try {/*from w ww .jav a2 s . c o m*/ if (status.isExists()) { new SDSDeleteFeature(session).delete(Collections.singletonList(renamed), connectionCallback, callback); } if (!new SimplePathPredicate(file.getParent()).test(renamed.getParent())) { // Change parent node new NodesApi(session.getClient()).moveNodes(StringUtils.EMPTY, Long.parseLong(new SDSNodeIdProvider(session).getFileid(renamed.getParent(), new DisabledListProgressListener())), new MoveNodesRequest().resolutionStrategy(MoveNodesRequest.ResolutionStrategyEnum.OVERWRITE) .addNodeIdsItem(Long.parseLong(new SDSNodeIdProvider(session).getFileid(file, new DisabledListProgressListener()))), null); } if (!StringUtils.equals(file.getName(), renamed.getName())) { if (containerService.isContainer(file)) { new NodesApi(session.getClient()).updateRoom(StringUtils.EMPTY, Long.parseLong(new SDSNodeIdProvider(session).getFileid(file, new DisabledListProgressListener())), new UpdateRoomRequest().name(renamed.getName()), null); } // Rename else if (file.isDirectory()) { new NodesApi(session.getClient()).updateFolder(StringUtils.EMPTY, Long.parseLong(new SDSNodeIdProvider(session).getFileid( new Path(renamed.getParent(), file.getName(), file.getType()), new DisabledListProgressListener())), new UpdateFolderRequest().name(renamed.getName()), null); } else { new NodesApi(session.getClient()).updateFile(StringUtils.EMPTY, Long.parseLong(new SDSNodeIdProvider(session).getFileid( new Path(renamed.getParent(), file.getName(), file.getType()), new DisabledListProgressListener())), new UpdateFileRequest().name(renamed.getName()), null); } } return new Path(renamed.getParent(), renamed.getName(), renamed.getType(), new PathAttributes(renamed.attributes()).withVersionId(file.attributes().getVersionId())); } catch (ApiException e) { throw new SDSExceptionMappingService().map("Cannot rename {0}", e, file); } }