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

MkRepo.java:68-69: Implement languages() method. Don't forget... #953 #994

Merged
merged 4 commits into from
Jan 26, 2015
Merged
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
17 changes: 12 additions & 5 deletions src/main/java/com/jcabi/github/mock/MkRepo.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@
import com.jcabi.github.Releases;
import com.jcabi.github.Repo;
import com.jcabi.github.RepoCommits;
import com.jcabi.github.RtLanguage;
import com.jcabi.github.Stars;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.json.JsonObject;
import javax.validation.constraints.NotNull;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.apache.commons.lang3.NotImplementedException;

/**
* Mock Github repo.
Expand All @@ -65,14 +67,12 @@
* @since 0.5
* @checkstyle ClassDataAbstractionCouplingCheck (500 lines)
* @checkstyle ClassFanOutComplexity (500 lines)
* @todo #923 Implement languages() method.
* Don't forget about unit tests.
*/
@Immutable
@Loggable(Loggable.DEBUG)
@ToString
@EqualsAndHashCode(of = {"storage", "self", "coords" })
@SuppressWarnings("PMD.TooManyMethods")
@SuppressWarnings({"PMD.TooManyMethods", "PMD.ExcessiveImports" })
final class MkRepo implements Repo {

/**
Expand Down Expand Up @@ -281,7 +281,14 @@ public Notifications notifications() {

@Override
public Iterable<Language> languages() {
throw new NotImplementedException("MkRepo#languages");
final List<Language> languages = new ArrayList<Language>(0);
final int java = 999;
languages.add(new RtLanguage("Java", java));
final int php = 888;
languages.add(new RtLanguage("PHP", php));
final int ruby = 777;
languages.add(new RtLanguage("Ruby", ruby));
return languages;
}

@Override
Expand Down
23 changes: 23 additions & 0 deletions src/test/java/com/jcabi/github/mock/MkRepoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
*/
package com.jcabi.github.mock;

import com.google.common.collect.Lists;
import com.jcabi.aspects.Tv;
import com.jcabi.github.Coordinates;
import com.jcabi.github.Language;
import com.jcabi.github.Milestones;
import com.jcabi.github.Repo;
import com.jcabi.github.Repos;
Expand Down Expand Up @@ -139,4 +142,24 @@ public void fetchNotifications() throws IOException {
);
MatcherAssert.assertThat(repo.notifications(), Matchers.notNullValue());
}

/**
* Repo can return Languages iterable.
* @throws IOException if some problem inside
*/
@Test
public void fetchLanguages() throws IOException {
final String user = "testuser4";
final Repo repo = new MkRepo(
new MkStorage.InFile(),
user,
new Coordinates.Simple(user, "testrepo4")
);
final Iterable<Language> languages = repo.languages();
MatcherAssert.assertThat(languages, Matchers.notNullValue());
MatcherAssert.assertThat(
Lists.newArrayList(languages),
Matchers.hasSize(Tv.THREE)
);
}
}