List of usage examples for java.util Collections singletonList
public static <T> List<T> singletonList(T o)
From source file:org.springframework.cloud.aws.messaging.QueueMessagingTemplateIntegrationTest.java
@Test public void sendAndReceive_ObjectMessageWithDefaultDestination_shouldUseTheStreamQueue() throws Exception { // Arrange//from ww w . ja v a2 s . co m List<String> payload = Collections.singletonList("myString"); // Act this.messagingTemplateWithCustomConverter.convertAndSend(payload); List<String> result = this.messagingTemplateWithCustomConverter.receiveAndConvert(StringList.class); // Assert assertEquals("myString", result.get(0)); }
From source file:com.heliosdecompiler.helios.tasks.DecompileAndSaveTask.java
@Override public void run() { File file = FileChooserUtil.chooseSaveLocation(Settings.LAST_DIRECTORY.get().asString(), Collections.singletonList("zip")); if (file == null) return;//from w ww . j a va 2 s. c o m if (file.exists()) { boolean delete = SWTUtil.promptForYesNo(Constants.REPO_NAME + " - Overwrite existing file", "The selected file already exists. Overwrite?"); if (!delete) { return; } } AtomicReference<Transformer> transformer = new AtomicReference<>(); Display display = Display.getDefault(); display.asyncExec(() -> { Shell shell = new Shell(Display.getDefault()); FillLayout layout = new FillLayout(); layout.type = SWT.VERTICAL; shell.setLayout(layout); Transformer.getAllTransformers(t -> { return t instanceof Decompiler || t instanceof Disassembler; }).forEach(t -> { Button button = new Button(shell, SWT.RADIO); button.setText(t.getName()); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { transformer.set(t); } }); }); Button ok = new Button(shell, SWT.NONE); ok.setText("OK"); ok.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { shell.close(); shell.dispose(); synchronized (transformer) { transformer.notify(); } } }); shell.pack(); SWTUtil.center(shell); shell.open(); }); synchronized (transformer) { try { transformer.wait(); } catch (InterruptedException e) { ExceptionHandler.handle(e); } } FileOutputStream fileOutputStream = null; ZipOutputStream zipOutputStream = null; try { file.createNewFile(); fileOutputStream = new FileOutputStream(file); zipOutputStream = new ZipOutputStream(fileOutputStream); Set<String> written = new HashSet<>(); for (Pair<String, String> pair : data) { LoadedFile loadedFile = Helios.getLoadedFile(pair.getValue0()); if (loadedFile != null) { String innerName = pair.getValue1(); byte[] bytes = loadedFile.getAllData().get(innerName); if (bytes != null) { if (loadedFile.getClassNode(pair.getValue1()) != null) { StringBuilder buffer = new StringBuilder(); transformer.get().transform(loadedFile.getClassNode(pair.getValue1()), bytes, buffer); String name = innerName.substring(0, innerName.length() - 6) + ".java"; if (written.add(name)) { zipOutputStream.putNextEntry(new ZipEntry(name)); zipOutputStream.write(buffer.toString().getBytes(StandardCharsets.UTF_8)); zipOutputStream.closeEntry(); } else { SWTUtil.showMessage("Duplicate entry occured: " + name); } } else { if (written.add(pair.getValue1())) { zipOutputStream.putNextEntry(new ZipEntry(pair.getValue1())); zipOutputStream.write(loadedFile.getAllData().get(pair.getValue1())); zipOutputStream.closeEntry(); } else { SWTUtil.showMessage("Duplicate entry occured: " + pair.getValue1()); } } } } } } catch (Exception e) { ExceptionHandler.handle(e); } finally { IOUtils.closeQuietly(zipOutputStream); IOUtils.closeQuietly(fileOutputStream); } }
From source file:com.logsniffer.web.controller.report.ReportsController.java
@RequestMapping(value = "/reports", method = RequestMethod.GET) ModelAndView listReports() {/*from w w w. ja v a2s.co m*/ ModelAndView mv = new ModelAndView("reports/list"); ReportsDashboard report = new ReportsDashboard(); report.setId(1); report.setCreatedAt(new Date()); report.setName("Log processing throughput"); mv.addObject("reports", Collections.singletonList(report)); return mv; }
From source file:com.hp.autonomy.aci.content.identifier.reference.ReferencesBuilder.java
/** * Appends the specified reference and section number to this instance, returning {@code this}. * * @param reference The reference to append * @param section The section number of the reference to append * @return {@code this}//w w w. j a v a2 s.co m */ @Override public ReferencesBuilder append(final String reference, final int section) { return doAppend(Collections.singletonList(new Reference(reference, section))); }
From source file:org.sakuli.services.forwarder.icinga2.model.builder.Icinga2OutputBuilderTest.java
@Test public void testBuildOk() throws Exception { TestSuite testSuite = new TestSuiteExampleBuilder().withState(TestSuiteState.OK).withId("TEST-SUITE-ID") .withTestCases(Collections .singletonList(new TestCaseExampleBuilder().withId("TEST-CASE-ID").buildExample())) .buildExample();//from w w w. ja v a2 s .c o m ReflectionTestUtils.setField(testling, "testSuite", testSuite); Assert.assertEquals(testling.build(), "[OK] Sakuli suite \"TEST-SUITE-ID\" ok (120.00s). (Last suite run: 17.08.14 14:02:00)\n" + "[OK] case \"TEST-CASE-ID\" ran in 3.00s - ok"); }
From source file:pl.edu.agh.iosr.lsf.RootController.java
@RequestMapping(value = "keyword", method = RequestMethod.GET) public List<String[]> listKeywords() { try {/*from w ww. j a va 2 s .c o m*/ return dh.listKeywords(); } catch (SQLException e) { return Collections.singletonList(new String[] { e.getMessage() }); } }
From source file:java2typescript.jaxrs.DescriptorGeneratorTest.java
@Test public void testJSGenerate() throws JsonGenerationException, JsonMappingException, IOException { ServiceDescriptorGenerator descGen = new ServiceDescriptorGenerator( Collections.singletonList(PeopleRestService.class)); descGen.generateJavascript("moduleName", out); }
From source file:com.moneydance.modules.features.importlist.io.ImportOneOperationTest.java
@Test public void testExecute() { AccountBook accountBook = AccountBook.fakeAccountBook(); Account fullRootAccount = new Account(accountBook); Account account = new Account(accountBook); AccountHelper.addSubAccount(fullRootAccount, account); accountBook.initializeAccounts(fullRootAccount); final StubContextFactory factory = new StubContextFactory(); StubContext context = factory.getContext(); FileOperation fileOperation = null;//from ww w .j a va2 s . c o m context.setAccountBook(accountBook); fileOperation = new ImportOneOperation(context, TrueFileFilter.TRUE, FalseFileFilter.FALSE); fileOperation.execute(Collections.singletonList(this.incomeFile)); fileOperation = new ImportOneOperation(context, TrueFileFilter.TRUE, FalseFileFilter.FALSE); fileOperation.execute(Collections.singletonList(this.creditcardFile)); fileOperation = new ImportOneOperation(context, TrueFileFilter.TRUE, FalseFileFilter.FALSE); fileOperation.execute(Collections.singletonList(this.noCategoryFile)); fileOperation = new ImportOneOperation(context, FalseFileFilter.FALSE, TrueFileFilter.TRUE); fileOperation.execute(Collections.singletonList(this.incomeFile)); fileOperation = new ImportOneOperation(context, FalseFileFilter.FALSE, TrueFileFilter.TRUE); fileOperation.execute(Collections.singletonList(this.creditcardFile)); fileOperation = new ImportOneOperation(context, FalseFileFilter.FALSE, TrueFileFilter.TRUE); fileOperation.execute(Collections.singletonList(this.noCategoryFile)); fileOperation = new ImportOneOperation(context, FalseFileFilter.FALSE, FalseFileFilter.FALSE); fileOperation.execute(Collections.singletonList(this.incomeFile)); fileOperation = new ImportOneOperation(context, FalseFileFilter.FALSE, FalseFileFilter.FALSE); fileOperation.execute(Collections.singletonList(this.creditcardFile)); fileOperation = new ImportOneOperation(context, FalseFileFilter.FALSE, FalseFileFilter.FALSE); fileOperation.execute(Collections.singletonList(this.noCategoryFile)); }
From source file:de.hybris.platform.acceleratorstorefrontcommons.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 w w . j ava 2s. c o 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(ThirdPartyConstants.SeoRobots.META_ROBOTS, ThirdPartyConstants.SeoRobots.INDEX_NOFOLLOW); final Breadcrumb loginBreadcrumbEntry = new Breadcrumb("#", getMessageSource().getMessage( "header.link.login", null, "header.link.login", 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.epam.ta.reportportal.core.project.UpdateProjectSettingsHandlerTest.java
@Test public void updateNotIssueSubType() { final UpdateIssueSubTypeRQ rq = new UpdateIssueSubTypeRQ(); final UpdateOneIssueSubTypeRQ subTypeRQ = new UpdateOneIssueSubTypeRQ(); final String notIssue = "nOt_issUe"; subTypeRQ.setTypeRef(notIssue);/*from w w w . j a va 2 s . c o m*/ subTypeRQ.setId(notIssue); rq.setIds(Collections.singletonList(subTypeRQ)); thrown.expect(ReportPortalException.class); thrown.expectMessage("Issue Type '" + notIssue + "' not found."); updateProjectSettingsHandler.updateProjectIssueSubType(project, user, rq); }