Skip to content

Commit

Permalink
Merge pull request Azure#1165 from jianghaolu/morefixes
Browse files Browse the repository at this point in the history
Fix some reported issues
  • Loading branch information
Martin Sawicki authored Oct 4, 2016
2 parents a9364e6 + 5f9a106 commit 27f57e3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ private ResourceUtils() { }
* @return the resource group name
*/
public static String groupFromResourceId(String id) {
return extractFromResourceId(id, "resourceGroups");
return extractFromResourceId(id, "resource[gG]roups");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public T withConnectionTimeout(long timeout, TimeUnit unit) {
@SuppressWarnings("unchecked")
@Override
public T withMaxIdleConnections(int maxIdleConnections) {
this.restClientBuilder = restClientBuilder.withMaxIdleConnections(5);
this.restClientBuilder = restClientBuilder.withMaxIdleConnections(maxIdleConnections);
return (T) this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import com.microsoft.azure.management.resources.fluentcore.model.implementation.CreatableUpdatableImpl;
import org.joda.time.DateTime;
import rx.Observable;
import rx.functions.Func1;
import rx.schedulers.Schedulers;

import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -184,13 +182,15 @@ public DeploymentImpl withNewResourceGroup(String resourceGroupName, Region regi
this.creatableResourceGroup = this.resourceManager.resourceGroups()
.define(resourceGroupName)
.withRegion(region);
addCreatableDependency(this.creatableResourceGroup);
this.resourceGroupName = resourceGroupName;
return this;
}

@Override
public DeploymentImpl withNewResourceGroup(Creatable<ResourceGroup> resourceGroupDefinition) {
this.resourceGroupName = resourceGroupDefinition.name();
addCreatableDependency(resourceGroupDefinition);
this.creatableResourceGroup = resourceGroupDefinition;
return this;
}
Expand Down Expand Up @@ -268,6 +268,9 @@ public DeploymentImpl withParametersLink(String uri, String contentVersion) {

@Override
public DeploymentImpl beginCreate() {
if (creatableResourceGroup != null) {
creatableResourceGroup.create();
}
DeploymentInner inner = new DeploymentInner()
.withProperties(new DeploymentProperties());
inner.properties().withMode(mode());
Expand All @@ -279,24 +282,6 @@ public DeploymentImpl beginCreate() {
return this;
}

@Override
public Observable<Deployment> createAsync() {
Observable<Deployment> observable;
if (this.creatableResourceGroup != null) {
observable = this.creatableResourceGroup.createAsync()
.subscribeOn(Schedulers.io())
.flatMap(new Func1<ResourceGroup, Observable<Deployment>>() {
@Override
public Observable<Deployment> call(ResourceGroup resourceGroup) {
return createResourceAsync();
}
});
} else {
observable = createResourceAsync();
}
return observable;
}

@Override
public Observable<Deployment> createResourceAsync() {
DeploymentInner inner = new DeploymentInner()
Expand Down Expand Up @@ -332,7 +317,8 @@ public Observable<Deployment> updateResourceAsync() {

@Override
public Deployment refresh() {
return null;
setInner(client.get(resourceGroupName(), name()));
return this;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.microsoft.azure.management.resources;

import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils;
import org.junit.Assert;
import org.junit.Test;

public class ResourceUtilsTests {
@Test
public void canExtractGroupFromId() throws Exception {
Assert.assertEquals("foo", ResourceUtils.groupFromResourceId("subscriptions/123/resourceGroups/foo/Microsoft.Bar/bars/bar1"));
Assert.assertEquals("foo", ResourceUtils.groupFromResourceId("subscriptions/123/resourcegroups/foo/Microsoft.Bar/bars/bar1"));
}
}

0 comments on commit 27f57e3

Please sign in to comment.