Skip to content

Commit

Permalink
#1254 GitlabRepo enable issues placeholder.
Browse files Browse the repository at this point in the history
  • Loading branch information
criske committed Oct 22, 2021
1 parent 8765cd0 commit b65580b
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 4 deletions.
66 changes: 66 additions & 0 deletions self-core-impl/src/main/java/com/selfxdsd/core/EmptyIssues.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/**
* Copyright (c) 2020-2021, Self XDSD Contributors
* All rights reserved.
* <p>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"),
* to read the Software only. Permission is hereby NOT GRANTED to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software.
* <p>
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package com.selfxdsd.core;

import com.selfxdsd.api.Issue;
import com.selfxdsd.api.Issues;

import javax.json.JsonObject;
import java.util.Collections;
import java.util.Iterator;

/**
* Empty issues representation.
* @author criske
* @version $Id$
* @since 0.0.95
*/
final class EmptyIssues implements Issues {

@Override
public Issue getById(final String issueId) {
return null;
}

@Override
public Issue received(final JsonObject issue) {
return null;
}

@Override
public Issue open(final String title,
final String body,
final String... labels) {
return null;
}

@Override
public Issues search(final String text, final String... labels) {
return null;
}

@Override
public Iterator<Issue> iterator() {
return Collections.emptyIterator();
}
}
15 changes: 11 additions & 4 deletions self-core-impl/src/main/java/com/selfxdsd/core/GitlabRepo.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import com.selfxdsd.api.*;
import com.selfxdsd.api.Labels;
import com.selfxdsd.api.storage.Storage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.json.JsonObject;
import java.net.URI;
Expand All @@ -34,12 +36,16 @@
* @author criske
* @version $Id$
* @since 0.0.1
* @todo #1246:60min Implement enabling of Issues for a GitLab repository.
* If GitLab doesn't support this functionality, the method should not do
* anything.
*/
final class GitlabRepo extends BaseRepo {

/**
* Logger.
*/
private static final Logger LOG = LoggerFactory.getLogger(
GitlabRepo.class
);

/**
* Constructor.
* @param resources Gitlab's JSON Resources.
Expand Down Expand Up @@ -151,7 +157,8 @@ public String fullName() {

@Override
public Issues enableIssues() {
throw new UnsupportedOperationException("Not yet implemented.");
LOG.warn("Gitlab doesn't support enabling issues...");
return new EmptyIssues();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,21 @@ public void returnsCommits() {
)
);
}

/**
* Gitlab doesn't support enabling issues.
*/
@Test
public void doesNotSupportEnableIssues(){
final Repo repo = new GitlabRepo(
Mockito.mock(JsonResources.class),
URI.create("https://gitlab.com/api/v4/projects/1"),
Mockito.mock(User.class),
Mockito.mock(Storage.class)
);
MatcherAssert.assertThat(
repo.enableIssues(),
Matchers.instanceOf(EmptyIssues.class)
);
}
}

1 comment on commit b65580b

@zoeself
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@criske I've closed the Issues [#1254] since their to-dos disappeared from the code.

The to-dos may have been removed in an earlier commit, but I've found it just now.

Please sign in to comment.