Skip to content

Commit

Permalink
yegor256#321 Integration test was upgraded to cover main use case
Browse files Browse the repository at this point in the history
  • Loading branch information
longtimeago committed Sep 30, 2014
1 parent aa6cc7b commit 2c95c9c
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 20 deletions.
6 changes: 2 additions & 4 deletions src/main/java/com/thindeck/MnBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@ public Usage usage() {
}

@Override
public Iterable<Repo> repos() {
return Collections.<Repo>singleton(
new MnBase.FakeRepo()
);
public Repos repos() {
throw new UnsupportedOperationException("#repos()");
}

@Override
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/thindeck/api/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public interface Base {
User user(URN urn);

/**
* Get all active repositories.
* @return Repositories
* Get active repositories.
* @return Repos
*/
@NotNull(message = "iterable of repos can't be null")
Iterable<Repo> repos();
@NotNull(message = "Repos can't be null")
Repos repos();

/**
* Get transaction for the particular task.
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/com/thindeck/dynamo/DyBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@
import com.jcabi.dynamo.Region;
import com.jcabi.urn.URN;
import com.thindeck.api.Base;
import com.thindeck.api.Repo;
import com.thindeck.api.Repos;
import com.thindeck.api.Task;
import com.thindeck.api.Txn;
import com.thindeck.api.User;
import java.util.Collections;

/**
* Dynamo implementation of the {@link Base}.
Expand Down Expand Up @@ -70,8 +69,8 @@ public User user(final URN urn) {
}

@Override
public Iterable<Repo> repos() {
return Collections.emptyList();
public Repos repos() {
throw new UnsupportedOperationException();
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/thindeck/life/RoutineTxns.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ final class RoutineTxns implements Runnable, Closeable {

@Override
public void run() {
for (final Repo repo : this.base.repos()) {
for (final Repo repo : this.base.repos().iterate()) {
for (final Task task : repo.tasks().open()) {
try {
this.base.txn(task).increment();
Expand Down
38 changes: 31 additions & 7 deletions src/test/java/dynamo/DyBaseITCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@
*/
package dynamo;

import com.jcabi.dynamo.Credentials;
import com.jcabi.dynamo.Region;
import com.thindeck.api.Base;
import com.thindeck.dynamo.DyBase;
import java.util.Collections;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mockito;

/**
* Integration case for {@link DyBase}.
Expand All @@ -45,15 +46,38 @@
public final class DyBaseITCase {

/**
* DyBase can make a {@link Repos}.
* DyBase can add a command.
* @throws Exception If there is some problem inside
* @todo #321 Uncomment the test it became passing.
*/
@Test
public void makesReposObject() throws Exception {
final Base base = new DyBase(Mockito.mock(Region.class));
@Ignore
public void canAddCommand() throws Exception {
final String command = "command";
MatcherAssert.assertThat(
base.repos(),
Matchers.notNullValue()
new DyBase(
DyBaseITCase.region()
).repos().add("test").tasks()
.add(
command, Collections.<String, String>emptyMap()
).command(),
Matchers.equalTo(command)
);
}

/**
* Create Region for tests.
* @return Region
*/
private static Region region() {
return new Region.Simple(
new Credentials.Direct(
new Credentials.Simple(
System.getProperty("dynamo.key"),
System.getProperty("dynamo.secret")
),
Integer.parseInt(System.getProperty("dynamo.port"))
)
);
}

Expand Down

0 comments on commit 2c95c9c

Please sign in to comment.