@Override public long performEntityCount() { //TODO, this really needs to be a task that writes this data somewhere since this will get //progressively slower as the system expands return (Long) getAllEntitiesObservable().countLong().toBlocking().last(); }
@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)); }
@Test public void writeLoadDelete() { ApplicationScope context = new ApplicationScopeImpl( new SimpleId( "organization" ) ); Entity newEntity = new Entity( new SimpleId( "test" ) ); EntityCollectionManager manager = factory.createCollectionManager( context ); Observable<Entity> observable = manager.write( newEntity, null ); Entity createReturned = observable.toBlocking().lastOrDefault( null ); assertNotNull( "Id was assigned", createReturned.getId() ); Observable<Entity> loadObservable = manager.load( createReturned.getId() ); Entity loadReturned = loadObservable.toBlocking().lastOrDefault( null ); assertEquals( "Same value", createReturned, loadReturned ); manager.mark( createReturned.getId(), null ).toBlocking().last(); loadObservable = manager.load( createReturned.getId() ); //load may return null, use last or default loadReturned = loadObservable.toBlocking().lastOrDefault( null ); assertNull( "Entity was deleted", loadReturned ); }
/** * 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(); }
/** * Deletes a resource group. * When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. * * @param resourceGroupName The name of the resource group to delete. The name is case insensitive. * @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 resourceGroupName) { deleteWithServiceResponseAsync(resourceGroupName).toBlocking().last().body(); }
@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 ); }
@Test public void testWriteReadEdgeTypeSource() 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.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().last(); assertEquals( "Correct edge returned", edge, returned ); //change edge type to be invalid, shouldn't get a result search = createSearchByEdge( edge.getSourceNode(), edge.getType() + "invalid", edge.getTimestamp(), null ); edges = gm.loadEdgesFromSource( 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 ); }
@Override public Page<PolicySetDefinitionInner> nextPage(String nextPageLink) { return listByManagementGroupNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } };
@Test public void testWriteInboundResponseDebug() { ctx.setDebugRequest(true); ctx.setDebugRequestHeadersOnly(true); Debug.writeDebugResponse(ctx, response, true).toBlocking().single(); List<String> debugLines = Debug.getRequestDebug(ctx); assertEquals(3, debugLines.size()); assertEquals("RESPONSE_INBOUND:: < STATUS: 200", debugLines.get(0)); assertEquals("RESPONSE_INBOUND:: < HDR: Content-Length:13", debugLines.get(1)); assertEquals("RESPONSE_INBOUND:: < HDR: lah:deda", debugLines.get(2)); }
/** * Deletes a VirtualHub. * * @param resourceGroupName The resource group name of the VirtualHub. * @param virtualHubName The name of the VirtualHub. * @throws IllegalArgumentException thrown if parameters fail the validation * @throws ErrorException 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 resourceGroupName, String virtualHubName) { deleteWithServiceResponseAsync(resourceGroupName, virtualHubName).toBlocking().last().body(); }
@Override public Set<String> getConnectionsAsTarget( final EntityRef entityRef ) { Preconditions.checkNotNull( entityRef, "entityRef cannot be null" ); final GraphManager graphManager = graphManagerFactory.createEdgeManager( applicationScope ); final SearchEdgeType searchByEdgeType = createConnectionTypeSearch( entityRef.asId() ); return graphManager.getEdgeTypesToTarget(searchByEdgeType).map( edgeName -> getConnectionNameFromEdgeName( edgeName ) ) .collect( () -> new HashSet<String>( ), ( r, s ) -> r.add(s) ).toBlocking().last(); }
@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 ); }
/** * 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 testWriteOutboundRequestDebug() { ctx.setDebugRequest(true); ctx.setDebugRequestHeadersOnly(true); Debug.writeDebugRequest(ctx, request, false).toBlocking().single(); List<String> debugLines = Debug.getRequestDebug(ctx); assertEquals(3, debugLines.size()); assertEquals("REQUEST_OUTBOUND:: > LINE: POST /some/where?k1=v1 HTTP/1.1", debugLines.get(0)); assertEquals("REQUEST_OUTBOUND:: > HDR: Content-Length:13", debugLines.get(1)); assertEquals("REQUEST_OUTBOUND:: > HDR: lah:deda", debugLines.get(2)); }
/** * Deletes the specified local network gateway. * * @param resourceGroupName The name of the resource group. * @param localNetworkGatewayName The name of the local network gateway. * @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 resourceGroupName, String localNetworkGatewayName) { deleteWithServiceResponseAsync(resourceGroupName, localNetworkGatewayName).toBlocking().last().body(); }
@Override public Set<String> getConnectionsAsSource( final EntityRef entityRef ) { Preconditions.checkNotNull(entityRef, "entityRef cannot be null"); final GraphManager graphManager = graphManagerFactory.createEdgeManager( applicationScope ); final SearchEdgeType searchByEdgeType = createConnectionTypeSearch( entityRef.asId() ); return graphManager.getEdgeTypesFromSource( searchByEdgeType ).map( edgeName -> getConnectionNameFromEdgeName( edgeName ) ) .collect( () -> new HashSet<String>(), ( r, s ) -> r.add( s ) ).toBlocking().last(); }
@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 ); }
@Override public Page<DeploymentExtendedInner> nextPage(String nextPageLink) { return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } };
@Test public void testWriteOutboundResponseDebug() { ctx.setDebugRequest(true); ctx.setDebugRequestHeadersOnly(true); Debug.writeDebugResponse(ctx, response, false).toBlocking().single(); List<String> debugLines = Debug.getRequestDebug(ctx); assertEquals(3, debugLines.size()); assertEquals("RESPONSE_OUTBOUND:: < STATUS: 200", debugLines.get(0)); assertEquals("RESPONSE_OUTBOUND:: < HDR: Content-Length:13", debugLines.get(1)); assertEquals("RESPONSE_OUTBOUND:: < HDR: lah:deda", debugLines.get(2)); }
/** * Deletes the specified load balancer. * * @param resourceGroupName The name of the resource group. * @param loadBalancerName The name of the load balancer. * @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 resourceGroupName, String loadBalancerName) { deleteWithServiceResponseAsync(resourceGroupName, loadBalancerName).toBlocking().last().body(); }