-
Notifications
You must be signed in to change notification settings - Fork 57
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 support for creation/download of Support Zip #197
Open
padas2
wants to merge
19
commits into
cdancy:master
Choose a base branch
from
padas2:feature/endpoints-for-support-zip
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 13 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
65a3d8f
Added SupportApi to create Support Zip, Added Live test for supportAp…
7689062
Adding back unintentionally removed imports
39c70d1
Removing custom credentials
bf3a0f8
Started work on getting task status
3d2f99f
Renaming SupportZipTask to SupportZipDetails, refactoring code to fol…
a97730d
Renaming SupportZip to SupportZipStatus, tried to use HAS-A pattern, …
39707c4
Removing changes introduced by IDE
d3d2c8b
Removing unecessary empty lines
9313612
Again adding code removed by IDE
e96591f
Removed all windows line endings
611d00c
restoring ide removed commits
b40793d
Adding licensing info
eca9dcd
Fixing PMD violations
a3726ae
Adding whitespace between class name and top most annotation, Adding …
6d6b096
A Rather big commit containing following changes: Changed SupportApi …
81e8958
Fixed CheckStyle and Licensing errors
e237b19
Fixed PMD rule violations
b26abdf
Initial changes for introducing fallbacks for support zip failures
b64e3f3
Reverting accidental conversion of Line endings back to LF type and a…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/java/com/cdancy/bitbucket/rest/domain/support/SupportZipDetails.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* 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.support; | ||
|
||
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 SupportZipDetails { | ||
public abstract String taskId(); | ||
|
||
public abstract Integer progressPercentage(); | ||
|
||
@Nullable | ||
public abstract String progressMessage(); | ||
|
||
@Nullable | ||
public abstract List<String> warnings(); | ||
|
||
public abstract String status(); | ||
|
||
@SerializedNames({"taskId", "progressPercentage", "progressMessage", "warnings", "status"}) | ||
public static SupportZipDetails create(final String taskId, | ||
final Integer progressPercentage, | ||
final String progressMessage, | ||
final List<String> warnings, | ||
final String status) { | ||
return new AutoValue_SupportZipDetails(taskId, | ||
progressPercentage, | ||
progressMessage, | ||
warnings, | ||
status); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
src/main/java/com/cdancy/bitbucket/rest/domain/support/SupportZipStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* 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.support; | ||
|
||
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 SupportZipStatus { | ||
public abstract String taskId(); | ||
|
||
public abstract Integer progressPercentage(); | ||
|
||
@Nullable | ||
public abstract String progressMessage(); | ||
|
||
@Nullable | ||
public abstract List<String> warnings(); | ||
|
||
public abstract String status(); | ||
|
||
public abstract String fileName(); | ||
|
||
@SerializedNames({"taskId", "progressPercentage", "progressMessage", "warnings", "status", "fileName"}) | ||
public static SupportZipStatus create(final String taskId, | ||
final Integer progressPercentage, | ||
final String progressMessage, | ||
final List<String> warnings, | ||
final String status, final String fileName) { | ||
return new AutoValue_SupportZipStatus(taskId, | ||
progressPercentage, | ||
progressMessage, | ||
warnings, | ||
status, | ||
fileName); | ||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/com/cdancy/bitbucket/rest/features/SupportApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* 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.features; | ||
|
||
import com.cdancy.bitbucket.rest.domain.support.SupportZipStatus; | ||
import com.cdancy.bitbucket.rest.domain.support.SupportZipDetails; | ||
import com.cdancy.bitbucket.rest.filters.BitbucketAuthenticationFilter; | ||
import org.jclouds.rest.annotations.RequestFilters; | ||
import javax.inject.Named; | ||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.POST; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
@Produces(MediaType.APPLICATION_JSON) | ||
@RequestFilters(BitbucketAuthenticationFilter.class) | ||
@Path("/rest/troubleshooting/latest/support-zip") | ||
@SuppressWarnings("PMD.AvoidDuplicateLiterals") | ||
public interface SupportApi { | ||
@Named("support-zip:create") | ||
@Consumes(MediaType.APPLICATION_JSON) | ||
@Path("/local") | ||
@POST | ||
SupportZipDetails createSupportZip(); | ||
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. Can we put a 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. Done though the lengths of links are very long(>= 210 chars long) |
||
|
||
@Named("support-zip:status") | ||
@Consumes(MediaType.APPLICATION_JSON) | ||
@Path("/status/task/{taskId}") | ||
@GET | ||
SupportZipStatus getSupportZipStatus(@PathParam("taskId") String taskId); | ||
} |
75 changes: 75 additions & 0 deletions
75
src/test/java/com/cdancy/bitbucket/rest/features/SupportApiLiveTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* 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.features; | ||
|
||
import com.cdancy.bitbucket.rest.BaseBitbucketApiLiveTest; | ||
import com.cdancy.bitbucket.rest.domain.support.SupportZipStatus; | ||
import com.cdancy.bitbucket.rest.domain.support.SupportZipDetails; | ||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
@Test(groups = "live", testName = "SupportApiLiveTest", singleThreaded = true) | ||
public class SupportApiLiveTest extends BaseBitbucketApiLiveTest { | ||
private SupportApi api() { | ||
return api.supportApi(); | ||
} | ||
|
||
@Test | ||
public void testSupportZipCreation() { | ||
final SupportZipDetails details = api().createSupportZip(); | ||
assertIntegrity(details); | ||
} | ||
|
||
@Test | ||
public void testSupportZipStatus() { | ||
final SupportZipDetails details = api().createSupportZip(); | ||
final SupportZipStatus supportZip = api().getSupportZipStatus(details.taskId()); | ||
assertIntegrity(supportZip); | ||
} | ||
|
||
private void assertIntegrity(final SupportZipStatus supportZip) { | ||
assertTaskId(supportZip.taskId()); | ||
assertTaskProgressMessage(supportZip.progressMessage()); | ||
assertTaskProgressPercentage(supportZip.progressPercentage()); | ||
assertTaskStatus(supportZip.status()); | ||
Assert.assertNotNull(supportZip.fileName()); | ||
} | ||
|
||
private void assertIntegrity(final SupportZipDetails supportZipTask) { | ||
assertTaskId(supportZipTask.taskId()); | ||
assertTaskProgressPercentage(supportZipTask.progressPercentage()); | ||
assertTaskProgressMessage(supportZipTask.progressMessage()); | ||
assertTaskStatus(supportZipTask.status()); | ||
} | ||
|
||
private void assertTaskProgressMessage(final String progressMessage) { | ||
Assert.assertNotNull(progressMessage); | ||
} | ||
|
||
private void assertTaskStatus(final String status) { | ||
Assert.assertTrue(!status.isEmpty()); | ||
} | ||
|
||
private void assertTaskId(final String taskId) { | ||
Assert.assertNotNull(taskId); | ||
} | ||
|
||
private void assertTaskProgressPercentage(final Integer progressPercentage) { | ||
Assert.assertNotNull(progressPercentage); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Lets put a line-break between the class name and this
Named
.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.
Done