Skip to content
This repository was archived by the owner on Mar 31, 2025. It is now read-only.

Commit 2716c59

Browse files
author
kobisuissa
committed
Merge remote-tracking branch 'origin/feature/allow-object-mapper-injection' into feature/allow-object-mapper-injection
# Conflicts: # .travis.yml # build.gradle # src/main/java/com/sybit/airtable/Airtable.java
2 parents 26e700c + 5179464 commit 2716c59

74 files changed

Lines changed: 3281 additions & 50 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ hs_err_pid*
1313
build/
1414
.gradle/
1515
src/test/resources/credentials.properties
16+
src/itest/resources/credentials.properties
17+
.nb-gradle-properties
18+
.nb-gradle/
1619

1720
# IDE
18-
.idea
21+
.idea
22+
src/itest/resources/credentials.properties

.nb-gradle-properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<gradle-project-properties>
3+
<!--DO NOT EDIT THIS FILE! - Used by the Gradle plugin of NetBeans.-->
4+
</gradle-project-properties>
Binary file not shown.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<gradle-project-properties>
3+
<!--DO NOT EDIT THIS FILE! - Used by the Gradle plugin of NetBeans.-->
4+
<auxiliary>
5+
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
6+
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
7+
<group>
8+
<file>file:/D:/Projekte/Sybit/Airtable/airtable.java/build.gradle</file>
9+
<file>file:/D:/Projekte/Sybit/Airtable/airtable.java/src/test/java/com/sybit/airtable/CustomObjectMapperTest.java</file>
10+
<file>file:/D:/Projekte/Sybit/Airtable/airtable.java/src/main/java/com/sybit/airtable/vo/Thumbnail.java</file>
11+
<file>file:/D:/Projekte/Sybit/Airtable/airtable.java/src/itest/java/com/sybit/airtable/TableSelectTest.java</file>
12+
<file>file:/D:/Projekte/Sybit/Airtable/airtable.java/.travis.yml</file>
13+
<file>file:/D:/Projekte/Sybit/Airtable/airtable.java/src/main/java/com/sybit/airtable/Airtable.java</file>
14+
<file>file:/D:/Projekte/Sybit/Airtable/airtable.java/src/main/java/com/sybit/airtable/vo/Attachment.java</file>
15+
</group>
16+
</open-files>
17+
<editor-bookmarks lastBookmarkId="0" xmlns="http://www.netbeans.org/ns/editor-bookmarks/2"/>
18+
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
19+
<group>
20+
<file>file:/D:/Projekte/Sybit/Airtable/airtable.java/.gitignore</file>
21+
<file>file:/D:/Projekte/Sybit/Airtable/airtable.java/src/main/java/com/sybit/airtable/vo/Thumbnail.java</file>
22+
<file>file:/D:/Projekte/Sybit/Airtable/airtable.java/src/itest/java/com/sybit/airtable/TableSelectTest.java</file>
23+
<file>file:/D:/Projekte/Sybit/Airtable/airtable.java/src/test/java/com/sybit/airtable/AirtableTest.java</file>
24+
<file>file:/D:/Projekte/Sybit/Airtable/airtable.java/src/main/java/com/sybit/airtable/Airtable.java</file>
25+
<file>file:/D:/Projekte/Sybit/Airtable/airtable.java/src/main/java/com/sybit/airtable/vo/Attachment.java</file>
26+
</group>
27+
</open-files>
28+
</auxiliary>
29+
</gradle-project-properties>

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ jdk:
44
before_install:
55
- chmod +x ./gradlew
66
script:
7-
- "./gradlew check sendCoverageToCodacy"
7+
- 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then bash ./gradlew check; fi'
8+
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then bash ./gradlew test integrationTest; fi'
9+
- "./gradlew sendCoverageToCodacy"
810
deploy:
911
- provider: releases
1012
api_key:
@@ -17,7 +19,7 @@ deploy:
1719
tags: true
1820
- provider: script
1921
skip_cleanup: true
20-
script: "./gradlew install bintrayUpload"
22+
script: "./gradlew -i bintrayUpload"
2123
on:
2224
repo: Sybit-Education/airtable.java
2325
tags: true

README.md

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ repositories {
3131

3232
## Initializing
3333

34-
It is required to initialize the Java API before it is used. At leased you have to pss your API-Key to get
34+
It is required to initialize the Java API before it is used. At leased you have to pass your API-Key to get
3535
access to Airtable:
3636

3737
```Java
@@ -41,9 +41,9 @@ Airtable airtable = new Airtable().configure();
4141

4242
### API-Key
4343
The API key could be passed to the app in different ways:
44-
* defining Java property `AIRTABLE_API_KEY` (e.g. `-DAIRTABLE_API_KEY=foo`).
45-
* defining OS environment variable `AIRTABLE_API_KEY` (e.g. `export AIRTABLE_API_KEY=foo`).
46-
* defining property file `credentials.properties` in root classpath containing key/value `AIRTABLE_API_KEY=foo`.
44+
* Defining Java property `AIRTABLE_API_KEY` (e.g. `-DAIRTABLE_API_KEY=foo`).
45+
* Defining OS environment variable `AIRTABLE_API_KEY` (e.g. `export AIRTABLE_API_KEY=foo`).
46+
* Defining property file `credentials.properties` in root classpath containing key/value `AIRTABLE_API_KEY=foo`.
4747
* On the other hand the API-key could also be added by using the method `Airtable.configure(String apiKey)`.
4848

4949
#### How to get API-Key
@@ -68,26 +68,26 @@ The API of Airtable itself is limited to 5 requests per second. If you exceed th
6868
need to wait 30 seconds before subsequent requests will succeed.
6969

7070
### Connecting to Airtable
71-
To use this Libraray you will need a Airtable Object. Simply create one! `Airtable airtable = new Airtable();`.
72-
This Object needs an API-Key or it won't work properly so `airtable.configure(AIRTABLE_API_KEY);`.
73-
Now the Airtable Object needs to know on which base you want access. This Method will return a Base Object which will be used in the Future.
71+
To use this libraray you will need an Airtable object. Simply create one: `Airtable airtable = new Airtable();`.
72+
This object needs an API-Key or it won't work properly so `airtable.configure(AIRTABLE_API_KEY);`.
73+
Now the Airtable object needs to know which base you want to access. This method will return a Base object which will be used in the future:
7474
`Base base = airtable.base(AIRTABLE_BASE);`
7575

76-
With the Base object you can perform all kind of Operations see more [here](#crud-operations-on-table-records).
76+
With the Base object you can perform all kind of operations see more at [CRUD Operations on Table Records](#crud-operations-on-table-records).
7777

7878

7979
## Object Mapping
80-
The Java implementation of the Airtable API provides automatic Object mapping. You can map any Table to your own Java Classes.
81-
But first you need to specify those Classes.
80+
The Java implementation of the Airtable API provides automatic object mapping. You can map any table to your own Java classes.
81+
But first you need to specify those classes.
8282

8383
### Create a Object
84-
The Java Objects represent records or 'values' in Airtable. So the Class attributes need to be adjusted to the Airtable Base.
84+
The Java objects represent records or 'values' in Airtable. So the class attributes need to be adjusted to the Airtable Base.
8585

8686
#### Example
8787

88-
In Aritable we got a Table Actor. The columns represent the Class attributes.
88+
In Airtable we got a table 'Actor'. The columns represent the class attributes.
8989

90-
This is how our Actor Table looks like:
90+
This is how our 'Actor' table looks like:
9191

9292
| Index | Name | Photo | Biography | Filmography |
9393
| :---: | :-----------: | :---------: | :-------: | :--------------------------: |
@@ -96,7 +96,7 @@ This is how our Actor Table looks like:
9696
| 3 | Al Pacino | Some Photos | Long Text | Reference to the Movie Table |
9797
| ... | ... | ... | ... | ... |
9898

99-
Now our Java Class should look like this:
99+
Now our Java class should look like this:
100100
```Java
101101
public class Actor {
102102

@@ -156,9 +156,9 @@ and add Getters and Setters for each attribute. The attribute types can be eithe
156156
`String Array` for references on other Tables or `Attachment` for attached photos and files.
157157

158158

159-
Now we got everything we need to create our first Airtable Table Object.
160-
We use the Java class we just wrote to specify what kind of Object should be saved in our Table. Then we tell our `base`-Object which Table we want to access.
161-
All the Records saved in our Airtable DB now should be in our local Table<JAVA CLASS> Object.
159+
Now we got everything we need to create our first Airtable table object.
160+
We use the Java class we just wrote to specify what kind of Object should be saved in our table. Then we tell our `base`-object which table we want to access.
161+
All the records saved in our Airtable Base now should be in our local Table<JAVA CLASS> Object.
162162

163163
Example:
164164

@@ -171,11 +171,11 @@ Example:
171171
```
172172

173173
### Basic Objects
174-
The Java implementation of the Airtable-API provides an implementation of basic Airtable objects such as attachments and Thumbnails.
174+
The Java implementation of the Airtable-API provides an implementation of basic Airtable objects such as attachments and thumbnails.
175175
Photos and attached files in Airtable are retrieved as `Attachment`s. Photos furthermore contain `Thumbnail`-Objects for different sizes.
176176

177177
#### Attachment
178-
All the `Attachment`-Objects got the following attributes:
178+
All the `Attachment`-objects got the following attributes:
179179

180180
* String `id`
181181
* String `url`
@@ -188,10 +188,10 @@ Photos additionally have:
188188
* Map<String,Thumbnail> `thumbnails`
189189

190190
#### Thumbnails
191-
A Thumbnail is generated for image files in Airtable. Thumbnails are bound to an Attachment Object as a key/value Map.
192-
The Keys are `small` and `large` for the different sizes. The Value is a `Thumbnail`-Object.
191+
A Thumbnail is generated for image files in Airtable. Thumbnails are bound to an `Attachment`-object as a key/value Map.
192+
The keys are `small` and `large` for the different sizes. The value is a `Thumbnail`-object.
193193

194-
A `Thumbnail`-Object got the following Attributes:
194+
A `Thumbnail`-object got the following Attributes:
195195

196196
* String `name`
197197
* String `url`
@@ -202,7 +202,7 @@ Note: The `name` of a Thumbnail Object is identical with it´s key ( `small` or
202202

203203
### Annotations
204204

205-
Use the Java Annotation `@SerializedName` of [Gson](https://github.com/google/gson) to annotate column names containing `-`, empty characters or other not in Java mappable characters.
205+
Use the annotation `@SerializedName` of [Gson](https://github.com/google/gson) to annotate column names containing `-`, empty characters or other not in Java mappable characters.
206206
The airtable.java API will respect these mappings automatically.
207207

208208
#### Example
@@ -215,7 +215,7 @@ The airtable.java API will respect these mappings automatically.
215215
private String name;
216216
```
217217
### Sort
218-
With the integrated Sort element you can retrieve a list of sort objects that specifies how the records will be ordered.
218+
With the integrated `Sort` element you can retrieve a list of sorted objects that specifies how the records will be ordered.
219219
Each sort object must have a field key specifying the name of the field to sort on, and an optional direction key that is either "asc" or "desc".
220220
The default direction is "asc".
221221

@@ -227,7 +227,7 @@ List<Movie> listMovies = movieTable.select(sort);
227227
```
228228
If you set the view parameter, the returned records in that view will be sorted by these fields.
229229

230-
Detailed Example see [TableParameterTest](https://github.com/Sybit-Education/airtable.java/blob/develop/src/test/java/com/sybit/airtable/TableParameterTest.java)
230+
Detailed example see [TableParameterTest](https://github.com/Sybit-Education/airtable.java/blob/develop/src/test/java/com/sybit/airtable/TableParameterTest.java)
231231

232232

233233
## CRUD-Operations on Table Records
@@ -296,6 +296,7 @@ Table<Actor> actorTable = base.table("Actors", Actor.class);
296296
Actor newActor = new Actor();
297297
newActor.setName("Neuer Actor");
298298
Actor test = actorTable.create(newActor);
299+
299300
```
300301

301302
Detailed example see [TableDestroyTest.java](https://github.com/Sybit-Education/airtable.java/blob/develop/src/test/java/com/sybit/airtable/TableCreateRecordTest.java)
@@ -312,6 +313,7 @@ Use `update` to update a record of table:
312313
// detailed Example see TableCreateTest.java
313314

314315
Actor marlonBrando = ...;
316+
315317
marlonBrando.setName("Marlon Brando");
316318
Actor updated = actorTable.update(marlonBrando);
317319
```
@@ -349,6 +351,10 @@ Short overview of features, which are supported:
349351

350352
We are glad to see your pull requests.
351353

354+
We use Travis as our continous integration build. Because of Travis security reasons on a Pull Request only JUnit tests run.
355+
The integration tests need a valid AIRTABLE_API_KEY which travis doesent provide on PR's from forked reposiorys.
356+
However the integration tests you wrote will run after the PR is confirmed and merged.
357+
352358
## Current status
353359

354360
The current status of our project is maintained on our agile board:
@@ -365,8 +371,9 @@ We use [Gradle](https://gradle.org) to compile and package project:
365371
+ build jar: `./gradlew jar` (The built JARs will be placed under `build/libs`.)
366372

367373
## Testing
368-
There are JUnit tests to verify the API.
369-
The tests are based on the Airtable template [Movies](https://airtable.com/templates/groups-clubs-and-hobbies/exprTnrH3YV8Vv9BI/favorite-movies) which could be created in your account.
374+
375+
There are JUnit tests and integration tests to verify the API.
376+
The integration tests are based on the Airtable template [Movies](https://airtable.com/templates/groups-clubs-and-hobbies/exprTnrH3YV8Vv9BI/favorite-movies) which could be created in your account.
370377
For testing, the JSON-responses are mocked by [WireMock](http://wiremock.org/).
371378

372379
# Other Airtable Projects

build.gradle

Lines changed: 66 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,27 @@ def getVersionName = { ->
2424

2525
buildscript {
2626
repositories {
27+
mavenLocal()
2728
jcenter()
2829
}
2930

30-
dependencies {
31-
classpath 'com.palantir:jacoco-coverage:0.4.0'
32-
classpath "com.smokejumperit.gradle.license:Gradle-License-Report:0.0.2"
33-
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
34-
}
31+
dependencies {
32+
classpath 'com.palantir:jacoco-coverage:0.4.0'
33+
classpath "com.smokejumperit.gradle.license:Gradle-License-Report:0.0.2"
34+
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
35+
}
3536
}
3637

37-
apply plugin: 'java'
38-
apply plugin: 'maven'
39-
apply plugin: 'com.palantir.jacoco-coverage'
40-
apply plugin: 'maven-publish'
41-
apply plugin: 'com.jfrog.bintray'
38+
allprojects {
39+
repositories {
40+
jcenter()
41+
}
42+
apply plugin: 'java'
43+
apply plugin: 'maven'
44+
apply plugin: 'maven-publish'
45+
apply plugin: 'com.palantir.jacoco-coverage'
46+
apply plugin: 'com.jfrog.bintray'
47+
}
4248

4349
group = 'com.sybit'
4450
version = getVersionName()
@@ -51,7 +57,26 @@ tasks.withType(JavaCompile) {
5157
options.encoding = 'UTF-8'
5258
}
5359

60+
sourceSets {
61+
integrationTest {
62+
compileClasspath += main.output + test.output
63+
runtimeClasspath += main.output + test.output
64+
// You can add other directories to the classpath like this:
65+
//runtimeClasspath += files('src/itest/resources/com/buransky')
66+
// Use "java" if you don't use Scala as a programming language
67+
java.srcDir file('src/itest/java')
68+
}
69+
// This is just to trick IntelliJ IDEA to add integration test
70+
// resources to classpath when running integration tests from
71+
// the IDE. It's is not a good solution but I don't know about
72+
// a better one.
73+
test {
74+
resources.srcDir file('src/itest/resources')
75+
}
76+
}
77+
5478
repositories {
79+
mavenLocal()
5580
jcenter()
5681
mavenCentral()
5782
maven { url "https://jitpack.io" }
@@ -60,6 +85,8 @@ repositories {
6085

6186
configurations {
6287
codacy
88+
integrationTestCompile.extendsFrom testCompile
89+
integrationTestRuntime.extendsFrom testRuntime
6390
}
6491

6592
dependencies {
@@ -95,6 +122,7 @@ artifacts {
95122
archives sourcesJar, javadocJar
96123
}
97124

125+
//task to send coverage data to Codacy
98126
task sendCoverageToCodacy(type: JavaExec, dependsOn: jacocoTestReport) {
99127
main = "com.codacy.CodacyCoverageReporter"
100128
classpath = configurations.codacy
@@ -106,28 +134,50 @@ task sendCoverageToCodacy(type: JavaExec, dependsOn: jacocoTestReport) {
106134
]
107135
}
108136

137+
task integrationTest(type: Test) {
138+
testClassesDir = sourceSets.integrationTest.output.classesDir
139+
classpath = sourceSets.integrationTest.runtimeClasspath
140+
// This is not needed, but I like to see which tests have run
141+
testLogging {
142+
events "passed", "skipped", "failed"
143+
}
144+
}
109145

110146
publishing {
111147
publications {
112-
mavenJava(MavenPublication) {
148+
149+
MyPublication(MavenPublication) {
150+
//we have to change scope from runtime to compile. Especially for Gson-lib.
151+
pom.withXml {
152+
asNode().dependencies.'*'.findAll() {
153+
it.scope.text() == 'runtime' && project.configurations.compile.allDependencies.find { dep ->
154+
dep.name == it.artifactId.text()
155+
}
156+
}.each { it.scope*.value = 'compile' }
157+
}
158+
113159
if (plugins.hasPlugin('war')) {
114160
from components.web
115161
} else {
116162
from components.java
117163
}
164+
groupId group
165+
artifactId rootProject.name
166+
version getVersionName()
118167

119168
artifact sourcesJar
120169
artifact javadocJar
121170
}
171+
122172
}
123173
}
124174

125175
bintray {
126176
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
127177
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
128178

129-
//publications = ['mavenJava']
130-
configurations = ['archives']
179+
publications = ['MyPublication']
180+
//configurations = ['archives']
131181

132182
dryRun = false //Whether to run this as dry-run, without deploying
133183
publish = true //If version should be auto published after an upload
@@ -144,3 +194,6 @@ bintray {
144194
}
145195
}
146196
}
197+
198+
integrationTest.mustRunAfter test
199+

0 commit comments

Comments
 (0)