Refine search
/** * Execute a remove document operation * * @param entity Entity to remove. * @param persistTo Persist to option. * @param replicateTo Replicate to option. * @return CAS value. */ @SuppressWarnings("unchecked") @Override public Long execute(final Object entity, final PersistTo persistTo, final ReplicateTo replicateTo) { Observable<Long> result = cmd.execute(entity, persistTo, replicateTo); return result.toBlocking().single(); }
@Test public void testWriteReadEdgeTypeVersionTarget() throws TimeoutException, InterruptedException { GraphManager gm = emf.createEdgeManager( scope ); final long earlyVersion = 10000l; Edge edge = createEdge( "source", "test", "target", earlyVersion ); gm.writeEdge( edge ).toBlocking().last(); //now test retrieving it SearchByEdgeType search = createSearchByEdge( edge.getTargetNode(), edge.getType(), edge.getTimestamp(), null ); Observable<MarkedEdge> edges = gm.loadEdgesToTarget( search ); //implicitly blows up if more than 1 is returned from "single" Edge returned = edges.toBlocking().single(); assertEquals( "Correct edge returned", edge, returned ); //change edge type to be invalid, shouldn't get a result search = createSearchByEdge( edge.getTargetNode(), edge.getType(), earlyVersion - 1, null ); edges = gm.loadEdgesToTarget( search ); //implicitly blows up if more than 1 is returned from "single" returned = edges.toBlocking().singleOrDefault( null ); assertNull( "Earlier version should not be returned", returned ); }
/** * Deletes a policy set definition. * * @param policySetDefinitionName The name of the policy set definition to delete. * @throws IllegalArgumentException thrown if parameters fail the validation * @throws ErrorResponseException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent */ public void delete(String policySetDefinitionName) { deleteWithServiceResponseAsync(policySetDefinitionName).toBlocking().single().body(); }
/** * Execute this command. * * @param entity Entity to use. * @param persistTo Persist to value. * @param replicateTo Replicate to value. * @param <R> Entity type. * @return Command result. */ public <R> R execute(final Object entity, final PersistTo persistTo, final ReplicateTo replicateTo) { Observable<R> result = cmd.execute(entity, persistTo, replicateTo); return result.toBlocking().single(); } }
/** * Gets the specified resource provider. * * @param resourceProviderNamespace The namespace of the resource provider. * @throws IllegalArgumentException thrown if parameters fail the validation * @throws CloudException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent * @return the ProviderInner object if successful. */ public ProviderInner get(String resourceProviderNamespace) { return getWithServiceResponseAsync(resourceProviderNamespace).toBlocking().single().body(); }
@Test public void testWriteReadEdgeTypeTarget() throws TimeoutException, InterruptedException { GraphManager gm = emf.createEdgeManager( scope ); Edge edge = createEdge( "source", "test", "target" ); gm.writeEdge( edge ).toBlocking().last(); //now test retrieving it SearchByEdgeType search = createSearchByEdge( edge.getTargetNode(), edge.getType(), edge.getTimestamp(), null ); Observable<MarkedEdge> edges = gm.loadEdgesToTarget( search ); //implicitly blows up if more than 1 is returned from "single" Edge returned = edges.toBlocking().single(); assertEquals( "Correct edge returned", edge, returned ); //change edge type to be invalid, shouldn't get a result search = createSearchByEdge( edge.getTargetNode(), edge.getType() + "invalid", edge.getTimestamp(), null ); edges = gm.loadEdgesToTarget( search ); //implicitly blows up if more than 1 is returned from "single" returned = edges.toBlocking().singleOrDefault( null ); assertNull( "Invalid type should not be returned", returned ); }
/** * Execute a remove document operation * * @param entityClass Entity class to remove. * @param id Entity id to remove. * @param persistTo Persist to option. * @param replicateTo Replicate to option. * @return CAS value. */ public Long execute(final Class<?> entityClass, final Object id, final PersistTo persistTo, final ReplicateTo replicateTo) { return ((AsyncRemoveCommand) cmd).execute(entityClass, id, persistTo, replicateTo) .toBlocking().single(); } }
@Override public Page<DeploymentExtendedInner> nextPage(String nextPageLink) { return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } };
@Test public void testWriteReadEdgeTypeVersionSource() throws TimeoutException, InterruptedException { GraphManager gm = emf.createEdgeManager( scope ); final long earlyVersion = 1000l; Edge edge = createEdge( "source", "test", "target", earlyVersion ); gm.writeEdge( edge ).toBlocking().last(); //now test retrieving it SearchByEdgeType search = createSearchByEdge( edge.getSourceNode(), edge.getType(), edge.getTimestamp(), null ); Observable<MarkedEdge> edges = gm.loadEdgesFromSource( search ); //implicitly blows up if more than 1 is returned from "single" Edge returned = edges.toBlocking().single(); assertEquals( "Correct edge returned", edge, returned ); //now test with an earlier version, we shouldn't get the edge back search = createSearchByEdge( edge.getSourceNode(), edge.getType(), earlyVersion - 1, null ); edges = gm.loadEdgesFromSource( search ); //implicitly blows up if more than 1 is returned from "single" returned = edges.toBlocking().singleOrDefault( null ); assertNull( "Earlier version should not be returned", returned ); }
/** * Run a {@link N1qlQuery#simple(Statement)} query. * * @param query N1qlQuery. * @param <T> Entity type. * @return A list of results. * @see N1Q#from(Class) */ default <T> List<T> query(final N1qlQuery query) { return async().<T> query(query).toBlocking().single(); }
@Override public Page<ResourceGroupInner> nextPage(String nextPageLink) { return listNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } };
@Test public void testWriteReadEdgeTypeTargetTypeSource() { GraphManager gm = emf.createEdgeManager( scope ); Edge edge = createEdge( "source", "test", "target" ); gm.writeEdge( edge ).toBlocking().last(); //now test retrieving it SearchByIdType search = createSearchByEdgeAndId( edge.getSourceNode(), edge.getType(), edge.getTimestamp(), edge.getTargetNode().getType(), null ); Observable<MarkedEdge> edges = gm.loadEdgesFromSourceByType( search ); //implicitly blows up if more than 1 is returned from "single" Edge returned = edges.toBlocking().single(); assertEquals( "Correct edge returned", edge, returned ); //change edge type to be invalid, shouldn't get a result search = createSearchByEdgeAndId( edge.getSourceNode(), edge.getType(), edge.getTimestamp(), edge.getTargetNode().getType() + "invalid", null ); edges = gm.loadEdgesFromSourceByType( search ); //implicitly blows up if more than 1 is returned from "single" returned = edges.toBlocking().singleOrDefault( null ); assertNull( "Invalid type should not be returned", returned ); }
/** * Run a {@link N1qlQuery#simple(Statement)} query. * * @param statement Statement. * @param <T> Entity type. * @return A list of results. * @see N1Q#from(Class) */ default <T> List<T> query(final Statement statement) { return async().<T> query(statement).toBlocking().single(); }
/** * Deletes a policy definition. * * @param policyDefinitionName The name of the policy definition to delete. * @throws IllegalArgumentException thrown if parameters fail the validation * @throws CloudException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent */ public void delete(String policyDefinitionName) { deleteWithServiceResponseAsync(policyDefinitionName).toBlocking().single().body(); }
@Test public void testWriteReadEdgeTypeTargetTypeTarget() { GraphManager gm = emf.createEdgeManager( scope ); ; Edge edge = createEdge( "source", "test", "target" ); gm.writeEdge( edge ).toBlocking().last(); //now test retrieving it SearchByIdType search = createSearchByEdgeAndId( edge.getTargetNode(), edge.getType(), edge.getTimestamp(), edge.getSourceNode().getType(), null ); Observable<MarkedEdge> edges = gm.loadEdgesToTargetByType( search ); //implicitly blows up if more than 1 is returned from "single" Edge returned = edges.toBlocking().single(); assertEquals( "Correct edge returned", edge, returned ); //change edge type to be invalid, shouldn't get a result search = createSearchByEdgeAndId( edge.getTargetNode(), edge.getType(), edge.getTimestamp(), edge.getSourceNode().getType() + "invalid", null ); edges = gm.loadEdgesToTargetByType( search ); //implicitly blows up if more than 1 is returned from "single" returned = edges.toBlocking().singleOrDefault( null ); assertNull( "Invalid type should not be returned", returned ); }
/** * Check whether a entity with the given ID does exist in the bucket. * * @param entityClass Entity class. * @param id Entity id. * @return True, if exists. */ default boolean exists(final Class<?> entityClass, final Object id) { return async().exists(entityClass, id).toBlocking().single(); }
/** * Deletes a policy definition at management group level. * * @param policyDefinitionName The name of the policy definition to delete. * @param managementGroupId The ID of the management group. * @throws IllegalArgumentException thrown if parameters fail the validation * @throws CloudException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent */ public void deleteAtManagementGroup(String policyDefinitionName, String managementGroupId) { deleteAtManagementGroupWithServiceResponseAsync(policyDefinitionName, managementGroupId).toBlocking().single().body(); }
/** * Run a {@link ViewQuery} query. * * @param query View query. * @param <T> Entity type. * @return Results. */ default <T> ViewQueryResult<T> query(final ViewQuery query) { return async().<T> query(query) .map(r -> new ViewQueryResult<>(r.getTotalRows(), r.getRows().toBlocking().single())) .toBlocking().single(); } }
@Override public Page<PolicyDefinitionInner> nextPage(String nextPageLink) { return listBuiltInNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } };
@Test public void testWriteInboundRequestDebug() { ctx.setDebugRequest(true); ctx.setDebugRequestHeadersOnly(true); Debug.writeDebugRequest(ctx, request, true).toBlocking().single(); List<String> debugLines = Debug.getRequestDebug(ctx); assertEquals(3, debugLines.size()); assertEquals("REQUEST_INBOUND:: > LINE: POST /some/where?k1=v1 HTTP/1.1", debugLines.get(0)); assertEquals("REQUEST_INBOUND:: > HDR: Content-Length:13", debugLines.get(1)); assertEquals("REQUEST_INBOUND:: > HDR: lah:deda", debugLines.get(2)); }