-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add possibility to get branch Model Condition #68
Changes from 5 commits
e2e10aa
796b972
2743b5c
ba3dbfe
a1ffd3b
8b48dea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.cdancy.bitbucket.rest.domain.branch; | ||
|
||
import com.google.auto.value.AutoValue; | ||
import org.jclouds.javax.annotation.Nullable; | ||
import org.jclouds.json.SerializedNames; | ||
|
||
@AutoValue | ||
public abstract class BranchConfiguration { | ||
|
||
@Nullable | ||
public abstract String refId(); | ||
|
||
public abstract boolean useDefault(); | ||
|
||
BranchConfiguration() { | ||
} | ||
|
||
@SerializedNames({ "refId", "useDefault" }) | ||
public static BranchConfiguration create(String refId, boolean useDefault) { | ||
return new AutoValue_BranchConfiguration(refId, useDefault); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.cdancy.bitbucket.rest.domain.branch; | ||
|
||
import com.cdancy.bitbucket.rest.domain.common.Error; | ||
import com.cdancy.bitbucket.rest.domain.common.ErrorsHolder; | ||
import com.cdancy.bitbucket.rest.utils.Utils; | ||
import com.google.auto.value.AutoValue; | ||
import org.jclouds.javax.annotation.Nullable; | ||
import org.jclouds.json.SerializedNames; | ||
|
||
import java.util.List; | ||
|
||
@AutoValue | ||
public abstract class BranchModelConfiguration implements ErrorsHolder { | ||
|
||
@Nullable | ||
public abstract BranchConfiguration development(); | ||
|
||
@Nullable | ||
public abstract BranchConfiguration production(); | ||
|
||
public abstract List<Type> types(); | ||
|
||
BranchModelConfiguration() { | ||
} | ||
|
||
@SerializedNames({ "development", "production", "types", "errors" }) | ||
public static BranchModelConfiguration create(BranchConfiguration development, BranchConfiguration production, | ||
List<Type> types, List<Error> errors) { | ||
return new AutoValue_BranchModelConfiguration(Utils.nullToEmpty(errors), development, production, Utils.nullToEmpty(types)); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.cdancy.bitbucket.rest.options; | ||
|
||
import com.cdancy.bitbucket.rest.domain.branch.BranchConfiguration; | ||
import com.cdancy.bitbucket.rest.domain.branch.BranchModelConfiguration; | ||
import com.cdancy.bitbucket.rest.domain.branch.Type; | ||
import com.google.auto.value.AutoValue; | ||
import org.jclouds.javax.annotation.Nullable; | ||
import org.jclouds.json.SerializedNames; | ||
|
||
import java.util.List; | ||
|
||
@AutoValue | ||
public abstract class CreateBranchModelConfiguration { | ||
|
||
public abstract BranchConfiguration development(); | ||
|
||
@Nullable | ||
public abstract BranchConfiguration production(); | ||
|
||
public abstract List<Type> types(); | ||
|
||
CreateBranchModelConfiguration() { | ||
} | ||
|
||
public static CreateBranchModelConfiguration create(BranchModelConfiguration configuration) { | ||
return new AutoValue_CreateBranchModelConfiguration(configuration.development(), configuration.production(), configuration.types()); | ||
} | ||
|
||
@SerializedNames({ "development", "production", "types" }) | ||
public static CreateBranchModelConfiguration create(BranchConfiguration development, BranchConfiguration production, List<Type> types) { | ||
return new AutoValue_CreateBranchModelConfiguration(development, production, types); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,17 +17,16 @@ | |
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another LiveTest to check for errors? Maybe named something like |
||
package com.cdancy.bitbucket.rest.features; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.fail; | ||
|
||
import com.cdancy.bitbucket.rest.BaseBitbucketApiLiveTest; | ||
import com.cdancy.bitbucket.rest.domain.branch.Branch; | ||
import com.cdancy.bitbucket.rest.domain.branch.BranchModel; | ||
import com.cdancy.bitbucket.rest.domain.branch.BranchModelConfiguration; | ||
import com.cdancy.bitbucket.rest.domain.branch.BranchPage; | ||
import com.cdancy.bitbucket.rest.domain.branch.BranchPermission; | ||
import com.cdancy.bitbucket.rest.domain.branch.BranchPermissionEnumType; | ||
import com.cdancy.bitbucket.rest.domain.branch.BranchPermissionPage; | ||
import com.cdancy.bitbucket.rest.domain.branch.Matcher; | ||
import com.cdancy.bitbucket.rest.domain.branch.Type; | ||
import com.cdancy.bitbucket.rest.domain.pullrequest.User; | ||
import com.cdancy.bitbucket.rest.options.CreateBranch; | ||
import org.testng.annotations.AfterClass; | ||
|
@@ -37,6 +36,9 @@ | |
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.fail; | ||
|
||
@Test(groups = "live", testName = "BranchApiLiveTest", singleThreaded = true) | ||
public class BranchApiLiveTest extends BaseBitbucketApiLiveTest { | ||
|
||
|
@@ -53,6 +55,7 @@ public class BranchApiLiveTest extends BaseBitbucketApiLiveTest { | |
String commitHash = "5284b6cec569346855710b535dafb915423110c2"; | ||
String existingGroup = "dev-group"; | ||
Long branchPermissionId = null; | ||
BranchModelConfiguration branchModelConfiguration = null; | ||
|
||
String defaultBranchId = "refs/heads/master"; | ||
|
||
|
@@ -62,6 +65,7 @@ public void init() { | |
assertThat(branch).isNotNull(); | ||
assertThat(branch.errors().isEmpty()).isTrue(); | ||
defaultBranchId = branch.id(); | ||
commitHash = branch.latestCommit(); | ||
} | ||
|
||
@Test | ||
|
@@ -136,12 +140,49 @@ public void testDeleteBranchPermission() { | |
} | ||
} | ||
|
||
@Test(dependsOnMethods = {"testCreateBranch", "testListBranches"}) | ||
public void testGetBranchModelConfiguration() { | ||
branchModelConfiguration = api().getModelConfiguration(projectKey, repoKey); | ||
checkDefaultBranchConfiguration(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we don't need to do this check twice than lets remove the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seen you pushed a commit but missed this. Not sure if you were planning on addressing with a subsequent commit. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I remove it, I need to readd it in another PR (#69) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gotcha ... yeah looking at that PR now. Ok lets keep it then. |
||
} | ||
|
||
private void checkDefaultBranchConfiguration() { | ||
assertThat(branchModelConfiguration).isNotNull(); | ||
assertThat(branchModelConfiguration.errors().isEmpty()).isTrue(); | ||
assertThat(branchModelConfiguration.development().refId()).isNull(); | ||
assertThat(branchModelConfiguration.development().useDefault()).isTrue(); | ||
assertThat(branchModelConfiguration.production()).isNull(); | ||
assertThat(branchModelConfiguration.types().size() == 4); | ||
for (Type type : branchModelConfiguration.types()) { | ||
switch (type.id()) { | ||
case BUGFIX: | ||
assertThat(type.prefix()).isEqualTo("bugfix/"); | ||
break; | ||
case HOTFIX: | ||
assertThat(type.prefix()).isEqualTo("hotfix/"); | ||
break; | ||
case FEATURE: | ||
assertThat(type.prefix()).isEqualTo("feature/"); | ||
break; | ||
case RELEASE: | ||
assertThat(type.prefix()).isEqualTo("release/"); | ||
break; | ||
default: | ||
break; | ||
} | ||
assertThat(type.enabled()).isTrue(); | ||
} | ||
} | ||
|
||
@AfterClass | ||
public void fin() { | ||
boolean success = api().updateDefault(projectKey, repoKey, defaultBranchId); | ||
assertThat(success).isTrue(); | ||
success = api().delete(projectKey, repoKey, "refs/heads/" + branchName); | ||
assertThat(success).isTrue(); | ||
if (branchModelConfiguration != null) { | ||
checkDefaultBranchConfiguration(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to do this check twice? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops, This line is for update |
||
} | ||
} | ||
|
||
private BranchApi api() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this file be here? Doesn't seem to be used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use in another PR (#69).