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

Commit 333531d

Browse files
authored
Merge pull request #17 from Sybit-Education/develop
Develop update
2 parents 796f216 + 3242c78 commit 333531d

71 files changed

Lines changed: 2712 additions & 42 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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ 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
1821
.idea

.travis.yml

Lines changed: 3 additions & 1 deletion
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:

README.md

Lines changed: 32 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
@@ -312,6 +312,7 @@ Use `update` to update a record of table:
312312
// detailed Example see TableCreateTest.java
313313

314314
Actor marlonBrando = ...;
315+
315316
marlonBrando.setName("Marlon Brando");
316317
Actor updated = actorTable.update(marlonBrando);
317318
```
@@ -349,6 +350,10 @@ Short overview of features, which are supported:
349350

350351
We are glad to see your pull requests.
351352

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

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

367372
## 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.
373+
There are JUnit tests and integration tests to verify the API.
374+
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.
370375
For testing, the JSON-responses are mocked by [WireMock](http://wiremock.org/).
371376

372377
# Other Airtable Projects

build.gradle

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def getVersionName = { ->
2424

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

@@ -56,7 +57,26 @@ tasks.withType(JavaCompile) {
5657
options.encoding = 'UTF-8'
5758
}
5859

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+
5978
repositories {
79+
mavenLocal()
6080
jcenter()
6181
mavenCentral()
6282
maven { url "https://jitpack.io" }
@@ -65,14 +85,15 @@ repositories {
6585

6686
configurations {
6787
codacy
88+
integrationTestCompile.extendsFrom testCompile
89+
integrationTestRuntime.extendsFrom testRuntime
6890
}
6991

7092
dependencies {
7193
compile group: 'com.mashape.unirest', name: 'unirest-java', version:'1.4.9'
72-
compile group: 'org.apache.httpcomponents', name: 'httpclient', version:'4.5.2'
73-
compile group: 'org.apache.httpcomponents', name: 'httpmime', version:'4.5.1'
94+
compile group: 'org.apache.httpcomponents', name: 'httpclient', version:'4.5.3'
7495
compile group: 'org.json', name: 'json', version:'20160810'
75-
compile group: 'com.google.code.gson', name: 'gson', version:'2.5'
96+
compile group: 'com.google.code.gson', name: 'gson', version:'2.8.0'
7697
compile group: 'commons-beanutils', name: 'commons-beanutils', version:'1.9.3'
7798
compile group: 'commons-io', name: 'commons-io', version:'2.5'
7899
compile group: 'org.slf4j', name: 'slf4j-api', version:'1.7.25'
@@ -113,6 +134,15 @@ task sendCoverageToCodacy(type: JavaExec, dependsOn: jacocoTestReport) {
113134
]
114135
}
115136

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+
}
145+
116146

117147
publishing {
118148
publications {
@@ -164,4 +194,7 @@ bintray {
164194
released = new Date()
165195
}
166196
}
167-
}
197+
}
198+
199+
integrationTest.mustRunAfter test
200+
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Fri Mar 10 12:20:33 CET 2017
1+
#Thu Apr 13 17:03:46 CEST 2017
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-3.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip

src/test/java/com/sybit/airtable/TableConverterTest.java renamed to src/itest/java/com/sybit/airtable/TableConverterTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
*/
66
package com.sybit.airtable;
77

8+
9+
import com.sybit.airtable.Base;
10+
import com.sybit.airtable.Table;
811
import com.sybit.airtable.exception.AirtableException;
912
import com.sybit.airtable.movies.Actor;
1013
import com.sybit.airtable.movies.Movie;
11-
import com.sybit.airtable.test.WireMockBaseTest;
14+
import com.sybit.airtable.mock.WireMockBaseTest;
1215
import com.sybit.airtable.vo.Attachment;
1316
import com.sybit.airtable.vo.Thumbnail;
1417
import java.util.List;

src/test/java/com/sybit/airtable/TableCreateRecordTest.java renamed to src/itest/java/com/sybit/airtable/TableCreateRecordTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
*/
66
package com.sybit.airtable;
77

8+
import com.sybit.airtable.Base;
9+
import com.sybit.airtable.Table;
810
import com.sybit.airtable.exception.AirtableException;
911
import com.sybit.airtable.movies.Actor;
1012
import com.sybit.airtable.movies.Movie;
11-
import com.sybit.airtable.test.WireMockBaseTest;
13+
import com.sybit.airtable.mock.WireMockBaseTest;
1214
import com.sybit.airtable.vo.Attachment;
1315
import java.lang.reflect.InvocationTargetException;
1416
import java.util.ArrayList;

src/test/java/com/sybit/airtable/TableDestroyTest.java renamed to src/itest/java/com/sybit/airtable/TableDestroyTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
*/
66
package com.sybit.airtable;
77

8+
import com.sybit.airtable.Base;
9+
import com.sybit.airtable.Table;
810
import com.sybit.airtable.exception.AirtableException;
911
import com.sybit.airtable.movies.Actor;
10-
import com.sybit.airtable.test.WireMockBaseTest;
12+
import com.sybit.airtable.mock.WireMockBaseTest;
1113
import java.util.List;
1214
import org.apache.http.client.HttpResponseException;
1315
import static org.junit.Assert.assertEquals;

src/test/java/com/sybit/airtable/TableFindTest.java renamed to src/itest/java/com/sybit/airtable/TableFindTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
*/
77
package com.sybit.airtable;
88

9+
import com.sybit.airtable.Base;
10+
import com.sybit.airtable.Table;
911
import com.sybit.airtable.exception.AirtableException;
1012
import com.sybit.airtable.movies.Actor;
11-
import com.sybit.airtable.test.WireMockBaseTest;
13+
import com.sybit.airtable.mock.WireMockBaseTest;
1214
import org.apache.http.client.HttpResponseException;
1315
import org.junit.Test;
1416

src/test/java/com/sybit/airtable/TableParameterTest.java renamed to src/itest/java/com/sybit/airtable/TableParameterTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@
55
*/
66
package com.sybit.airtable;
77

8+
import com.sybit.airtable.Base;
9+
import com.sybit.airtable.Query;
10+
import com.sybit.airtable.Sort;
11+
import com.sybit.airtable.Table;
812
import com.sybit.airtable.exception.AirtableException;
913
import com.sybit.airtable.movies.Movie;
10-
import com.sybit.airtable.test.WireMockBaseTest;
14+
import com.sybit.airtable.mock.WireMockBaseTest;
1115
import java.util.List;
1216
import org.apache.http.client.HttpResponseException;
1317
import static org.junit.Assert.assertEquals;

0 commit comments

Comments
 (0)