Skip to content

Commit

Permalink
Merge pull request #6 from agorapulse/feature/multiproject-maven-cent…
Browse files Browse the repository at this point in the history
…ral-and-mock

multiproject, maven central, mock implementation
  • Loading branch information
musketyr committed May 6, 2021
2 parents fa7e6f6 + ce51bb7 commit 00e9c3b
Show file tree
Hide file tree
Showing 48 changed files with 1,391 additions and 257 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
${{ runner.os }}-gradle-
- uses: eskatos/gradle-command-action@v1
with:
arguments: check jacocoTestReport coveralls --stacktrace
arguments: check coveralls --stacktrace
- name: Show Reports
uses: actions/upload-artifact@v1
if: failure()
Expand Down
42 changes: 26 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,41 @@ name: Release

on:
release:
types: [published]
types: [ published ]
jobs:
release:
name: Release
runs-on: ubuntu-latest
env:
GRADLE_OPTS: "-Xmx6g -Xms4g"
BINTRAY_USER: ${{ secrets.BINTRAY_USER }}
BINTRAY_KEY: ${{ secrets.BINTRAY_KEY }}
steps:
- uses: actions/checkout@v1
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Semantic Version
id: version
uses: ncipollo/semantic-version-action@v1
- uses: eskatos/gradle-command-action@v1
with:
arguments: bintrayUpload -Pversion=${{ steps.version.outputs.tag }}
- uses: actions/checkout@v1
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Semantic Version
id: version
uses: ncipollo/semantic-version-action@v1
- name: Decode PGP
id: write_file
uses: timheuer/base64-to-file@v1
with:
fileName: 'secret.pgp'
encodedString: ${{ secrets.SIGNING_SECRET_KEY_BASE64 }}
- uses: eskatos/gradle-command-action@v1
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_SECRET_KEY_PATH: ${{ steps.write_file.outputs.filePath }}
with:
arguments: gitPublishPush publishToSonatype closeAndReleaseSonatypeStagingRepository -Pversion=${{ steps.version.outputs.tag }} -Prelease=true -Dorg.ajoberstar.grgit.auth.username=${{ secrets.AGORAPULSE_BOT_PERSONAL_TOKEN }} --stacktrace
ping:
name: Notify Upstream Repositories
runs-on: ubuntu-latest
needs: [release]
needs: [ release ]
strategy:
matrix:
repository:
Expand All @@ -39,7 +49,7 @@ jobs:
- name: Dispatch to ${{ matrix.repository }}
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.PERSONAL_TOKEN }}
token: ${{ secrets.AGORAPULSE_BOT_PERSONAL_TOKEN }}
repository: ${{ matrix.repository }}
event-type: ap-new-version-released-event
client-payload: '{ "group": "com.agorapulse", "module": "notification", "version": "${{ steps.version.outputs.tag }}", "property" : "micronaut.facebook.sdk.version", "github" : ${{ toJson(github) }} }'
56 changes: 52 additions & 4 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,19 @@ Micronaut provider for https://restfb.com/[restfb Facebook Java client].

[source,groovy]
----
compile 'com.agorapulse:micronaut-facebook-sdk:0.1.0'
implementation 'com.agorapulse:micronaut-facebook-sdk:{version}'
// grails support
implementation 'com.agorapulse:micronaut-facebook-sdk-grails:{version}'
// flowable connection support
implementation 'com.agorapulse:micronaut-facebook-sdk-rx:{version}'
// facebook stored request support
implementation 'com.agorapulse:micronaut-facebook-sdk-fsr:{version}'
// facebook server mock using Ersatz server
testImplementation 'com.agorapulse:micronaut-facebook-sdk-mock:{version}'
----

== Configuration
Expand Down Expand Up @@ -73,7 +85,7 @@ public class MyJavaService {
}
/**
* Fetches the recent posts.
* Fetches the recent post - requires micronaut-facebook-sdk-rx.
* @param token Facebook API token
* @return Flowable iterating over the recent posts.
*/
Expand All @@ -84,7 +96,7 @@ public class MyJavaService {
}
----

If you are using RxJava you can use `FlowableConnection` to create `Flowable` wrapping `com.restfb.Connection` to simplify pagination.
If you are using RxJava you can use `micronaut-facebook-sdk-rx` which provides `FlowableConnection` to create `Flowable` wrapping `com.restfb.Connection` to simplify pagination.

See https://restfb.com/documentation/ for further reference.

Expand Down Expand Up @@ -116,7 +128,7 @@ class MyGroovyService {
}
/**
* Fetches the recent posts.
* Fetches the recent posts - requires micronaut-facebook-sdk-rx.
* @param token Facebook API token
* @return Flowable iterating over the recent posts.
*/
Expand All @@ -126,3 +138,39 @@ class MyGroovyService {
}
----


=== Testing

You can use `micronaut-facebook-sdk-mock` to inject bean `TestFacebookApplication` into your tests. Then you can use `mockApi` method
to set up the mock Facebook server.

See `FacebookApiResponse` and `TestFacebookApplicationExtensions` for further details.

[source,groovy]
----
@MicronautTest
@CompileDynamic
class TestFacebookApplicationSpec extends Specification {
Fixt fixt = Fixt.create(TestFacebookApplicationSpec)
@Inject @AutoCleanup TestFacebookApplication facebook
void 'get me'() {
given:
facebook.mockApi {
get('/v10.0/me') {
just fixt.readText('me.json')
}
}
when:
User me = facebook.createClient().fetchObject('/me', User)
then:
me
me.name == 'Facebook SDK'
}
}
----
Loading

0 comments on commit 00e9c3b

Please sign in to comment.