-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Allow an outline builder to build outlines for various classes
- Add response builder test - Add repository base class
- Loading branch information
Showing
5 changed files
with
79 additions
and
34 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
core/src/main/java/org/chodavarapu/datamill/db/Repository.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,26 @@ | ||
package org.chodavarapu.datamill.db; | ||
|
||
import org.chodavarapu.datamill.reflection.Outline; | ||
import org.chodavarapu.datamill.reflection.OutlineBuilder; | ||
import rx.Observable; | ||
|
||
import java.util.function.BiFunction; | ||
|
||
/** | ||
* @author Ravi Chodavarapu (rchodava@gmail.com) | ||
*/ | ||
public class Repository<T> { | ||
private Client client; | ||
private OutlineBuilder outlineBuilder; | ||
private Class<T> entityClass; | ||
|
||
protected Repository(Client client, OutlineBuilder outlineBuilder, Class<T> entityClass) { | ||
this.client = client; | ||
this.outlineBuilder = outlineBuilder; | ||
this.entityClass = entityClass; | ||
} | ||
|
||
protected <R> Observable<R> executeQuery(BiFunction<Client, Outline<T>, Observable<R>> executor) { | ||
return executor.apply(client, outlineBuilder.build(entityClass)); | ||
} | ||
} |
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
21 changes: 21 additions & 0 deletions
21
core/src/test/java/org/chodavarapu/datamill/http/impl/ResponseBuilderTest.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,21 @@ | ||
package org.chodavarapu.datamill.http.impl; | ||
|
||
import org.chodavarapu.datamill.http.ResponseBuilder; | ||
import org.chodavarapu.datamill.http.Status; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* @author Ravi Chodavarapu (rchodava@gmail.com) | ||
*/ | ||
public class ResponseBuilderTest { | ||
@Test | ||
public void responseCodes() { | ||
ResponseBuilder builder = new ResponseBuilderImpl(); | ||
assertEquals(Status.NOT_FOUND, builder.notFound().toBlocking().last().status()); | ||
assertEquals(Status.OK, builder.ok().toBlocking().last().status()); | ||
assertEquals(Status.UNAUTHORIZED, builder.unauthorized().toBlocking().last().status()); | ||
assertEquals(Status.NO_CONTENT, builder.noContent().toBlocking().last().status()); | ||
} | ||
} |
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
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