List of usage examples for java.util.concurrent CompletableFuture get
@SuppressWarnings("unchecked") public T get() throws InterruptedException, ExecutionException
From source file:org.eclipse.winery.accountability.AccountabilityManagerImplIntegrationTest.java
@Test void addParticipant() throws Exception { String processId = "ServiceTemplateWithAllReqCapVariants"; String participantBlockchainId = "0x0000000000000000000000000111111222223333"; String participantName = "Ghareeb"; CompletableFuture<String> authorize = this.provenance.authorize(processId, participantBlockchainId, participantName);/*from w w w . ja v a 2 s. co m*/ assertNotNull(authorize.get()); CompletableFuture<AuthorizationInfo> authorization = this.provenance.getAuthorization(processId); AuthorizationInfo authorizationInfo = authorization.get(); assertTrue(authorizationInfo.isAuthorized(participantBlockchainId)); }
From source file:org.apache.sling.commons.messaging.mail.internal.SimpleMailServiceIT.java
@Test public void sendWithoutAuthentication() throws Exception { final Dictionary<String, Object> properties = MailBuilderConfigurations.minimal(); createFactoryConfiguration(FACTORY_PID, properties); final MessageService messageService = getService(MessageService.class); final CompletableFuture<Result> future = messageService.send("simple test message", "recipient@example.net"); try {//from ww w.j ava 2s . co m future.get(); } catch (Exception e) { logger.info(e.getMessage(), e); assertTrue(ExceptionUtils.getRootCause(e) instanceof AuthenticationFailedException); } }
From source file:org.apache.sling.commons.messaging.mail.internal.SimpleMailServiceIT.java
@Test public void send() throws Exception { final Dictionary<String, Object> properties = MailBuilderConfigurations.full(wiser.getServer().getPort()); createFactoryConfiguration(FACTORY_PID, properties); final MessageService messageService = getService(MessageService.class); final CompletableFuture<Result> future = messageService.send("simple test message", "recipient@example.net"); final MailResult result = (MailResult) future.get(); final String message = new String(result.getMessage(), StandardCharsets.UTF_8); logger.info("message: {}", message); // TODO assert }
From source file:org.apache.sling.commons.messaging.mail.internal.SimpleMailServiceIT.java
@Test public void sendWithData() throws Exception { final Dictionary<String, Object> properties = MailBuilderConfigurations.full(wiser.getServer().getPort()); createFactoryConfiguration(FACTORY_PID, properties); final MessageService messageService = getService(MessageService.class); final Map configuration = Collections.singletonMap("mail.subject", "Testing the Simple Mail Service with a custom subject"); final Map data = Collections.singletonMap("mail", configuration); final CompletableFuture<Result> future = messageService.send("simple test message", "recipient@example.net", data);//from w ww . ja v a2s.c o m final MailResult result = (MailResult) future.get(); final String message = new String(result.getMessage(), StandardCharsets.UTF_8); logger.info("message: {}", message); // TODO assert }
From source file:com.redhat.coolstore.api_gateway.ApiGatewayController.java
@CrossOrigin(maxAge = 3600) @RequestMapping(method = RequestMethod.GET, value = "/cart/{cartId}", produces = MediaType.APPLICATION_JSON_VALUE) @ApiOperation("Get the user's cart") @ResponseBody//w w w . ja va 2 s. c o m public ShoppingCart getCart(@PathVariable String cartId) throws ExecutionException, InterruptedException { final CompletableFuture<ShoppingCart> cart = CompletableFuture .supplyAsync(() -> feignClientFactory.getCartClient().getService().getCart(cartId), es); return cart.get(); }
From source file:com.redhat.coolstore.api_gateway.ApiGatewayController.java
@CrossOrigin(maxAge = 3600) @RequestMapping(method = RequestMethod.POST, value = "/cart/checkout/{cartId}", produces = MediaType.APPLICATION_JSON_VALUE) @ApiOperation("Cart checkout") @ResponseBody/*w w w .j a v a 2 s.c o m*/ public ShoppingCart checkout(@PathVariable String cartId) throws ExecutionException, InterruptedException { final CompletableFuture<ShoppingCart> cart = CompletableFuture .supplyAsync(() -> feignClientFactory.getCartClient().getService().checkout(cartId), es); return cart.get(); }
From source file:com.ikanow.aleph2.security.service.IkanowV1DataModificationChecker.java
protected Date queryLastModifiedDate(Boolean wasIndexed) { if (wasIndexed) { SingleQueryComponent<JsonNode> query = CrudUtils.allOf() .orderBy(new Tuple2<String, Integer>("modified", -1)).limit(1); CompletableFuture<Cursor<JsonNode>> fCursor = getCommunityDb().getObjectsBySpec(query, Arrays.asList("modified"), true); try {//w w w . j av a 2 s . c o m Iterator<JsonNode> it = fCursor.get().iterator(); if (it.hasNext()) { JsonNode n = it.next(); logger.debug(n); JsonNode modifiedNode = n.get("modified"); if (modifiedNode != null) { String modifiedText = modifiedNode.asText(); // logger.debug(modifiedText); // example Thu Aug 13 15:44:08 CDT 2015 SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy"); lastModified = sdf.parse(modifiedText); // logger.debug(lastModified); } } } catch (Throwable e) { logger.error("queryLastModifiedDate caught Exception", e); } } return null; }
From source file:com.redhat.coolstore.api_gateway.ApiGatewayController.java
@CrossOrigin(maxAge = 3600) @RequestMapping(method = RequestMethod.POST, value = "/cart/{cartId}/{itemId}/{quantity}", produces = MediaType.APPLICATION_JSON_VALUE) @ApiOperation("Add to user's cart") @ResponseBody/*from www.j a va 2 s. c o m*/ public ShoppingCart addToCart(@PathVariable String cartId, @PathVariable String itemId, @PathVariable int quantity) throws ExecutionException, InterruptedException { final CompletableFuture<ShoppingCart> cart = CompletableFuture.supplyAsync( () -> feignClientFactory.getCartClient().getService().addToCart(cartId, itemId, quantity), es); return cart.get(); }
From source file:com.redhat.coolstore.api_gateway.ApiGatewayController.java
@CrossOrigin(maxAge = 3600) @RequestMapping(method = RequestMethod.DELETE, value = "/cart/{cartId}/{itemId}/{quantity}", produces = MediaType.APPLICATION_JSON_VALUE) @ApiOperation("Delete from the user's cart") @ResponseBody/*from w ww . j a va 2s . c om*/ public ShoppingCart deleteFromCart(@PathVariable String cartId, @PathVariable String itemId, @PathVariable int quantity) throws ExecutionException, InterruptedException { final CompletableFuture<ShoppingCart> cart = CompletableFuture.supplyAsync( () -> feignClientFactory.getCartClient().getService().deleteFromCart(cartId, itemId, quantity), es); return cart.get(); }
From source file:de.ks.file.FileViewController.java
@Override public void duringSave(FileContainer<?> model) { fileReferences.keySet().retainAll(files); if (this.fileReferences.isEmpty()) { log.info("No files to save for {}", model); }//from w w w .ja v a2s .c om this.fileReferences.entrySet().forEach(entry -> { try { File file = entry.getKey(); CompletableFuture<FileReference> cf = entry.getValue(); FileReference fileReference = cf.get(); model.getFiles().remove(fileReference); model.addFileReference(PersistentWork.reload(fileReference));//ensure it is saved if (fileReference.getId() > 0) { return; } fileStore.scheduleCopy(fileReference, file); String search = "file:///" + file.getAbsolutePath(); String replacement = FileReference.FILESTORE_VAR + fileReference.getMd5Sum() + File.separator + file.getName(); String newDescription = StringUtils.replace(model.getDescription(), search, replacement); model.setDescription(newDescription); log.info("Adding file reference {}", fileReference); PersistentWork.persist(fileReference); } catch (InterruptedException | ExecutionException e) { log.error("Could not get fileReference for file {}", entry.getKey()); throw new RuntimeException(e); } }); }