Skip to content
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

Feature/blocker comments #403

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/main/java/com/cdancy/bitbucket/rest/BitbucketApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.cdancy.bitbucket.rest.features.BuildStatusApi;
import com.cdancy.bitbucket.rest.features.CommentsApi;
import com.cdancy.bitbucket.rest.features.CommitsApi;
import com.cdancy.bitbucket.rest.features.CompareApi;
import com.cdancy.bitbucket.rest.features.DefaultReviewersApi;
import com.cdancy.bitbucket.rest.features.FileApi;
import com.cdancy.bitbucket.rest.features.HookApi;
Expand Down Expand Up @@ -54,6 +55,9 @@ public interface BitbucketApi extends Closeable {
@Delegate
BuildStatusApi buildStatusApi();

@Delegate
CompareApi compareApi();

@Delegate
CommentsApi commentsApi();

Expand Down Expand Up @@ -91,6 +95,7 @@ public interface BitbucketApi extends Closeable {
TagApi tagApi();

@Delegate
@Deprecated
TasksApi tasksApi();

@Delegate
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package com.cdancy.bitbucket.rest.domain.comment;

import com.cdancy.bitbucket.rest.BitbucketUtils;
import com.cdancy.bitbucket.rest.domain.common.Error;
import com.cdancy.bitbucket.rest.domain.common.ErrorsHolder;
import com.cdancy.bitbucket.rest.domain.pullrequest.Author;
import com.google.auto.value.AutoValue;
import com.google.gson.JsonElement;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.json.SerializedNames;

import java.util.List;
import java.util.Map;

@AutoValue
public abstract class BlockerComments implements ErrorsHolder {
public abstract Map<String, JsonElement> properties();

public abstract int id();

public abstract int version();

@Nullable
public abstract String text();

@Nullable
public abstract Author author();

public abstract long createdDate();

public abstract long updatedDate();
public abstract boolean threadResolved();
public abstract Comments.Severity severity();
public abstract Comments.TaskState state();

@Nullable
public abstract PermittedOperations permittedOperations();

@Nullable
public abstract Author resolver();

BlockerComments() {
}

@SerializedNames({ "properties", "id", "version", "text", "author",
"createdDate", "updatedDate", "resolver", "threadResolved", "state", "severity", "permittedOperations", "errors" })
public static BlockerComments create(final Map<String, JsonElement> properties,
final int id,
final int version,
final String text,
final Author author,
final long createdDate,
final long updatedDate,
final Author resolver,
final Boolean threadResolved,
final Comments.TaskState state,
final Comments.Severity severity,
final PermittedOperations permittedOperations,
final List<Error> errors) {

return new AutoValue_BlockerComments(BitbucketUtils.nullToEmpty(errors),
BitbucketUtils.nullToEmpty(properties),
id,
version,
text,
author,
createdDate,
updatedDate,
threadResolved,
severity,
state,
permittedOperations,
resolver);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@

@AutoValue
public abstract class Comments implements ErrorsHolder, LinksHolder {
public enum Severity {
NORMAL,
BLOCKER
}

public enum TaskState {
OPEN,
PENDING,
RESOLVED
}

public abstract Map<String, JsonElement> properties();

Expand All @@ -51,24 +61,35 @@ public abstract class Comments implements ErrorsHolder, LinksHolder {

public abstract long updatedDate();

/**
* Not defined for activities
* @return
*/
@Nullable
public abstract Severity severity();
/**
* Not defined for activities
* @return
*/
@Nullable
public abstract TaskState state();

public abstract List<Comments> comments();

public abstract List<Task> tasks();


@Nullable
public abstract Anchor anchor();

@Nullable
public abstract Link link();

@Nullable
public abstract PermittedOperations permittedOperations();

Comments() {
}

@SerializedNames({ "properties", "id", "version", "text", "author",
"createdDate", "updatedDate", "comments", "tasks", "anchor", "link", "links",
"createdDate", "updatedDate", "comments", "severity", "state", "anchor", "link", "links",
"permittedOperations", "errors" })
public static Comments create(final Map<String, JsonElement> properties,
final int id,
Expand All @@ -78,26 +99,28 @@ public static Comments create(final Map<String, JsonElement> properties,
final long createdDate,
final long updatedDate,
final List<Comments> comments,
final List<Task> tasks,
final Severity severity,
final TaskState state,
final Anchor anchor,
final Link link,
final Links links,
final PermittedOperations permittedOperations,
final List<Error> errors) {
return new AutoValue_Comments(BitbucketUtils.nullToEmpty(errors),
links,

return new AutoValue_Comments(BitbucketUtils.nullToEmpty(errors),
links,
BitbucketUtils.nullToEmpty(properties),
id,
version,
text,
author,
createdDate,
updatedDate,
BitbucketUtils.nullToEmpty(comments),
BitbucketUtils.nullToEmpty(tasks),
anchor,
link,
id,
version,
text,
author,
createdDate,
updatedDate,
severity,
state,
BitbucketUtils.nullToEmpty(comments),
anchor,
link,
permittedOperations);
}
}
26 changes: 26 additions & 0 deletions src/main/java/com/cdancy/bitbucket/rest/domain/commit/Diff.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.cdancy.bitbucket.rest.domain.commit;

import com.cdancy.bitbucket.rest.domain.common.Error;
import com.cdancy.bitbucket.rest.domain.common.ErrorsHolder;
import com.cdancy.bitbucket.rest.domain.pullrequest.Path;
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 Diff implements ErrorsHolder {
@SerializedNames({"errors", "source", "destination", "truncated", "hunks"})
public static Diff create(@Nullable final List<Error> errors, final Path source, final Path destination, final boolean truncated, final List<DiffHunk> hunks) {
return new AutoValue_Diff(errors, source, destination, truncated, hunks);
}

public abstract Path source();

public abstract Path destination();

public abstract boolean truncated();

public abstract List<DiffHunk> hunks();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.cdancy.bitbucket.rest.domain.commit;

import com.google.auto.value.AutoValue;
import org.jclouds.json.SerializedNames;

import java.util.List;

@AutoValue
public abstract class DiffHunk {
@SerializedNames({"sourceLine", "sourceSpan", "destinationLine", "destinationSpan", "truncated", "segments"})
public static DiffHunk create(final Integer sourceLine, final Integer sourceSpan, final Integer destinationLine, final Integer destinationSpan, final boolean truncated, final List<DiffHunkSegment> segments) {
return new AutoValue_DiffHunk(sourceLine, sourceSpan, destinationLine, destinationSpan, truncated, segments);
}

public abstract Integer sourceLine();

public abstract Integer sourceSpan();

public abstract Integer destinationLine();

public abstract Integer destinationSpan();

public abstract boolean truncated();

public abstract List<DiffHunkSegment> segments();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.cdancy.bitbucket.rest.domain.commit;

import com.google.auto.value.AutoValue;
import org.jclouds.json.SerializedNames;

import java.util.List;

@AutoValue
public abstract class DiffHunkSegment {
@SerializedNames({"type", "lines", "truncated"})
public static DiffHunkSegment create(final String type, final List<DiffHunkSegmentLine> lines, final boolean truncated) {
return new AutoValue_DiffHunkSegment(type, lines, truncated);
}

/**
* @return "REMOVED", "ADDED", "CONTEXT", ?
*/
public abstract String type();

public abstract List<DiffHunkSegmentLine> lines();

public abstract boolean truncated();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.cdancy.bitbucket.rest.domain.commit;

import com.google.auto.value.AutoValue;
import org.jclouds.json.SerializedNames;

@AutoValue
public abstract class DiffHunkSegmentLine {
@SerializedNames({"source", "destination", "line", "truncated"})
public static DiffHunkSegmentLine create(final Integer source, final Integer destination, final String line, final boolean truncated) {
return new AutoValue_DiffHunkSegmentLine(source, destination, line, truncated);
}

public abstract Integer source();

public abstract Integer destination();

public abstract String line();

public abstract boolean truncated();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.cdancy.bitbucket.rest.domain.commit;

import com.cdancy.bitbucket.rest.domain.common.Error;
import com.cdancy.bitbucket.rest.domain.common.ErrorsHolder;
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 DiffPage implements ErrorsHolder {
@SerializedNames({"errors", "fromHash", "toHash", "contextLines", "whitespace", "truncated", "diffs"})
public static DiffPage create(@Nullable final List<Error> errors, final String fromHash, final String toHash, final Integer contextLines, final String whitespace, final boolean truncated, final List<Diff> diffs) {
return new AutoValue_DiffPage(errors, fromHash, toHash, contextLines, whitespace, truncated, diffs);
}

public abstract String fromHash();

public abstract String toHash();

public abstract Integer contextLines();

public abstract String whitespace();

public abstract boolean truncated();

public abstract List<Diff> diffs();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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.pullrequest;

import com.cdancy.bitbucket.rest.BitbucketUtils;
import com.cdancy.bitbucket.rest.domain.comment.BlockerComments;
import com.cdancy.bitbucket.rest.domain.common.Error;
import com.cdancy.bitbucket.rest.domain.common.ErrorsHolder;
import com.cdancy.bitbucket.rest.domain.common.Page;
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 BlockerCommentsPage implements Page<BlockerComments>, ErrorsHolder {

@SerializedNames({ "start", "limit", "size",
"nextPageStart", "isLastPage", "values", "errors" })
public static BlockerCommentsPage create(@Nullable final int start,
@Nullable final int limit,
@Nullable final int size,
@Nullable final int nextPageStart,
@Nullable final boolean isLastPage,
@Nullable final List<BlockerComments> values,
@Nullable final List<Error> errors) {

return new AutoValue_BlockerCommentsPage(start,
limit,
size,
nextPageStart,
isLastPage,
BitbucketUtils.nullToEmpty(values),
BitbucketUtils.nullToEmpty(errors));
}
}
Loading