Skip to content
This repository was archived by the owner on Mar 31, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
f4f2c2e
Finishing Thumbnail and Attachement Converter, started with tests
Mar 24, 2017
05f89c1
Test for Converter and README changes
Mar 24, 2017
b8e2a13
Documentation
Mar 24, 2017
363475f
Merge branch 'develop' into feauture/AttachementConverter
Mar 24, 2017
a13bc4f
Changes in Documentation
Mar 24, 2017
5d3e719
Renamed Thumbnail Converter
Mar 24, 2017
ae2ed0a
Documentation changes
Mar 24, 2017
987b1e9
Dokumentation
Mar 28, 2017
db89130
Codacy Improvements
Mar 28, 2017
50e3d8d
Codacy
Mar 28, 2017
5912b68
Codacy
Mar 28, 2017
ce81955
Merge pull request #2 from Sybit-Education/feauture/AttachementConverter
stritti Mar 28, 2017
960540b
Merge branch 'develop'
stritti Mar 28, 2017
dbcaa00
moved converter to subpackage
stritti Mar 29, 2017
4d7b01d
Implemented Destroy Method with Tests
Mar 30, 2017
05a0750
Documentation
Mar 30, 2017
15b8490
Implemented Create Method
Mar 30, 2017
c0a2928
Comments etc
Mar 30, 2017
3ee8c71
- Adding configuration class.
stritti Mar 31, 2017
70c6bb5
Merge branch 'develop' of https://github.com/Sybit-Education/airtable…
stritti Mar 31, 2017
39bcf12
Create Method
Mar 31, 2017
ae89c1f
Implemented Create
Mar 31, 2017
e6fddec
Fixed Things
Mar 31, 2017
cfd89f1
update readme
stritti Mar 31, 2017
3cfb083
fix javadoc error
stritti Mar 31, 2017
1d30b07
Merge pull request #4 from Sybit-Education/develop
stritti Mar 31, 2017
089e23a
updated/improved readme
stritti Apr 3, 2017
8e36f54
updated readme
stritti Apr 3, 2017
545b375
cleand API
stritti Apr 3, 2017
7f05f1d
travis caching
stritti Apr 3, 2017
ca42e0a
update travis build
stritti Apr 3, 2017
4d9ee48
disable cache
stritti Apr 3, 2017
0e19782
sendCoverageToCodacy
stritti Apr 3, 2017
e4c4fee
sendCoverageToCodacy
stritti Apr 3, 2017
ef4803e
gradlew check sendCoverageToCodacy
stritti Apr 3, 2017
4d0d5e9
./gradlew
stritti Apr 3, 2017
bc06fee
Extended Tests, implemented checkProperties
Apr 4, 2017
ae9050d
Updated Readme and Documentation
Apr 4, 2017
03bdd06
Readme changes
Apr 4, 2017
56d6916
Merge branch 'develop' into feature/CreateRecord
Apr 4, 2017
d59a904
Fixed Readme
Apr 4, 2017
586b5e0
removed unused imports
Apr 4, 2017
361d315
Merge pull request #9 from Sybit-Education/feature/CreateRecord
Apr 4, 2017
b646320
extracted Method checkPropertiesOfAttachement
Apr 4, 2017
f3f295d
Implemented Update TableRecord with Tests
Apr 4, 2017
bc24394
Updated Documentation
Apr 4, 2017
eb370cc
Updated Documentation
Apr 4, 2017
9d8162b
updated Readme
Apr 4, 2017
cdcd46b
Updated Readme
Apr 4, 2017
fe367f8
updated Readme
Apr 4, 2017
baf2ae0
Updated Readme
Apr 4, 2017
56cce06
Merge branch 'develop'
stritti Apr 5, 2017
5d9f272
switch commands
stritti Apr 5, 2017
2f78eb1
Merge branch 'develop'
stritti Apr 5, 2017
63caa96
updated file filter
stritti Apr 5, 2017
cb1be8a
deploy correction
stritti Apr 5, 2017
5dd3985
travis deploy
stritti Apr 5, 2017
5f78b9a
Edited Readme
Apr 7, 2017
800bad7
updated Codacy Issues
Apr 7, 2017
4470ca2
Started Parameter Tests
Apr 7, 2017
883cf1b
Merge pull request #10 from Sybit-Education/feature/UpdateRecord
stritti Apr 8, 2017
4a43083
Merge pull request #11 from Sybit-Education/develop
stritti Apr 8, 2017
fbd9675
Implemented Tests for filter and additional Filter Methods
Apr 10, 2017
eacb0e3
Edited Readme
Apr 10, 2017
68a913d
Merge branch 'develop' into feature/queryParams
Apr 10, 2017
bb9f1ae
updated readme
stritti Apr 10, 2017
b13ac0f
Merge branch 'develop'
stritti Apr 10, 2017
a26f38b
typo corrected
stritti Apr 10, 2017
91683f0
updated gradle-file
stritti Apr 10, 2017
385b1dc
bintrayupload
stritti Apr 10, 2017
56dea95
corrected bintray-task
stritti Apr 10, 2017
56ab51d
one more try
stritti Apr 10, 2017
cadd442
Merge pull request #12 from Sybit-Education/feature/queryParams
Apr 10, 2017
d9d7f43
Edited Readme
Apr 10, 2017
63fcf60
Edited Readme
Apr 10, 2017
328dcbc
Class Table is now public
Apr 11, 2017
d2eaff1
Deleted Property file
Apr 11, 2017
c6ee700
Merge branch 'master' into develop
Apr 11, 2017
042e846
reordered
stritti Apr 11, 2017
69ee23d
edited Javadoc
Apr 11, 2017
7ce0c1e
Merge branch 'develop' of https://github.com/Sybit-Education/airtable…
Apr 11, 2017
522ca1c
Merge pull request #13 from Sybit-Education/develop
Apr 11, 2017
17fdd07
verbose logging for bintray
stritti Apr 12, 2017
01aa397
bintray publish
stritti Apr 12, 2017
4d042fd
one more try
stritti Apr 12, 2017
cb07eac
Change scope of required libraries to "compile"
stritti Apr 13, 2017
7d09213
change scope of dependend libs to compile
stritti Apr 13, 2017
941e2ac
improved script
stritti Apr 13, 2017
c029059
allow injection of custom object mapper
Apr 18, 2017
5179464
Merge branch 'master' into feature/allow-object-mapper-injection
stritti Apr 27, 2017
26e700c
Merge branch 'develop' of https://github.com/hubrick/airtable.java in…
Apr 27, 2017
2716c59
Merge remote-tracking branch 'origin/feature/allow-object-mapper-inje…
Apr 27, 2017
5cc333f
Merge branch 'develop' of https://github.com/hubrick/airtable.java in…
Apr 27, 2017
0bbf382
Merge branch 'develop' of https://github.com/hubrick/airtable.java in…
Apr 28, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ Table<Actor> actorTable = base.table("Actors", Actor.class);
Actor newActor = new Actor();
newActor.setName("Neuer Actor");
Actor test = actorTable.create(newActor);

```

Detailed example see [TableDestroyTest.java](https://github.com/Sybit-Education/airtable.java/blob/develop/src/test/java/com/sybit/airtable/TableCreateRecordTest.java)
Expand Down Expand Up @@ -370,6 +371,7 @@ We use [Gradle](https://gradle.org) to compile and package project:
+ build jar: `./gradlew jar` (The built JARs will be placed under `build/libs`.)

## Testing

There are JUnit tests and integration tests to verify the API.
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.
For testing, the JSON-responses are mocked by [WireMock](http://wiremock.org/).
Expand Down
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ task integrationTest(type: Test) {
}
}


publishing {
publications {

Expand Down
138 changes: 138 additions & 0 deletions src/itest/java/com/sybit/airtable/TableSelectJacksonOMTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
package com.sybit.airtable;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.mashape.unirest.http.ObjectMapper;
import com.sybit.airtable.exception.AirtableException;
import com.sybit.airtable.movies.ActorSerializedNames;
import com.sybit.airtable.movies.Movie;
import com.sybit.airtable.mock.WireMockBaseTest;
import org.apache.http.client.HttpResponseException;
import org.junit.Before;
import org.junit.Test;

import java.io.IOException;
import java.util.List;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.any;
import static com.github.tomakehurst.wiremock.client.WireMock.anyUrl;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

/**
* Created by kobisuissa on 18/04/17.
*/
public class TableSelectJacksonOMTest extends WireMockBaseTest {

@Before
public void setup() throws AirtableException {
airtable.configure(new ObjectMapper() {

final com.fasterxml.jackson.databind.ObjectMapper objectMapper = new com.fasterxml.jackson.databind.ObjectMapper();

@Override
public <T> T readValue(final String value, final Class<T> valueType) {
try {
return objectMapper.readValue(value, valueType);
} catch (IOException e) {
throw new RuntimeException(e);
}
}

@Override
public String writeValue(final Object value) {
try {
return objectMapper.writeValueAsString(value);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
});
airtable.setEndpointUrl("http://localhost:8080/v0");

//set 404 as default
stubFor(any(anyUrl())
.atPriority(10)
.willReturn(aResponse()
.withStatus(404)
.withBody("{\"error\":{\"type\":\"NOT_FOUND\",\"message\":\"Not found\"}}")));

}

@Test
public void testSelectTable() throws AirtableException, HttpResponseException {

Base base = airtable.base("appe9941ff07fffcc");

List<Movie> retval = base.table("Movies", Movie.class).select();
assertNotNull(retval);
assertEquals(10, retval.size());
Movie mov = retval.get(0);
assertEquals("Sister Act", mov.getName());
}

@Test
public void testSelectTableMaxRecords() throws AirtableException, HttpResponseException {

Base base = airtable.base("appe9941ff07fffcc");

List<Movie> retval = base.table("Movies", Movie.class).select(2);
assertNotNull(retval);
assertEquals(2, retval.size());
Movie mov = retval.get(0);
assertEquals("Sister Act", mov.getName());
}

@Test
public void testSelectTableSorted() throws AirtableException, HttpResponseException {

Base base = airtable.base("appe9941ff07fffcc");
Table table = base.table("Movies", Movie.class);

List<Movie> retval = table.select(new Sort("Name", Sort.Direction.asc));
assertNotNull(retval);
assertEquals(10, retval.size());
Movie mov = retval.get(0);
assertEquals("Billy Madison", mov.getName());

retval = table.select(new Sort("Name", Sort.Direction.desc));
assertNotNull(retval);
assertEquals(10, retval.size());
mov = retval.get(0);
assertEquals("You've got Mail", mov.getName());

}

@Test
public void testSelectTableView() throws AirtableException, HttpResponseException {

Base base = airtable.base("appe9941ff07fffcc");

List<Movie> retval = base.table("Movies", Movie.class).select("Main View");
assertNotNull(retval);
assertEquals(10, retval.size());
Movie mov = retval.get(0);
assertEquals("The Godfather", mov.getName());
}

@Test(expected = AirtableException.class)
public void testSelectNonExistingTable() throws AirtableException, HttpResponseException {

Base base = airtable.base("appe9941ff07fffcc");

List<Movie> retval = base.table("NotExists", Movie.class).select();
assertNotNull(retval);
}

@Test
public void testSelectWithSerializedNames() throws AirtableException, HttpResponseException {

Base base = airtable.base("appe9941ff07fffcc");

List<ActorSerializedNames> retval = base.table("SerializedNames", ActorSerializedNames.class).select();
assertNotNull(retval);
assertEquals("Marlon Brando", retval.get(0).getName());
}

}
61 changes: 50 additions & 11 deletions src/main/java/com/sybit/airtable/Airtable.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package com.sybit.airtable;


import com.mashape.unirest.http.ObjectMapper;
import com.mashape.unirest.http.Unirest;
import com.sybit.airtable.converter.ListConverter;
import com.sybit.airtable.converter.MapConverter;
Expand Down Expand Up @@ -54,11 +55,24 @@ public class Airtable {
* Configure, <code>AIRTABLE_API_KEY</code> passed by Java property, enviroment variable
* or within credentials.properties.
*
* @return configured Airtable object.
* @return An Airtable instance configured with GsonObjectMapper
* @throws com.sybit.airtable.exception.AirtableException Missing API-Key
*/
@SuppressWarnings("UnusedReturnValue")
public Airtable configure() throws AirtableException {
return this.configure(new GsonObjectMapper());
}

/**
* Configure, <code>AIRTABLE_API_KEY</code> passed by Java property, enviroment variable
* or within credentials.properties.
*
* @param objectMapper A custom ObjectMapper implementation
* @return An Airtable instance configured with supplied ObjectMapper
* @throws com.sybit.airtable.exception.AirtableException Missing API-Key
*/
@SuppressWarnings("UnusedReturnValue")
public Airtable configure(ObjectMapper objectMapper) throws AirtableException {

LOG.info( "System-Property: Using Java property '-D" + AIRTABLE_API_KEY + "' to get apikey.");
String airtableApi = System.getProperty(AIRTABLE_API_KEY);
Expand All @@ -71,7 +85,7 @@ public Airtable configure() throws AirtableException {
airtableApi = getCredentialProperty(AIRTABLE_API_KEY);
}

return this.configure(airtableApi);
return this.configure(airtableApi, objectMapper);
}


Expand All @@ -80,12 +94,25 @@ public Airtable configure() throws AirtableException {
* Configure Airtable.
*
* @param apiKey API-Key of Airtable.
* @return
* @return An Airtable instance configured with GsonObjectMapper
* @throws com.sybit.airtable.exception.AirtableException Missing API-Key
*/
@SuppressWarnings("WeakerAccess")
public Airtable configure(String apiKey) throws AirtableException {
return configure(new Configuration(apiKey, Configuration.ENDPOINT_URL));
return configure(apiKey, new GsonObjectMapper());
}

/**
* Configure Airtable.
*
* @param apiKey API-Key of Airtable.
* @param objectMapper A custom ObjectMapper implementation
* @return
* @throws com.sybit.airtable.exception.AirtableException Missing API-Key
*/
@SuppressWarnings("WeakerAccess")
public Airtable configure(String apiKey, ObjectMapper objectMapper) throws AirtableException {
return configure(new Configuration(apiKey, Configuration.ENDPOINT_URL), objectMapper);
}

/**
Expand All @@ -96,6 +123,19 @@ public Airtable configure(String apiKey) throws AirtableException {
*/
@SuppressWarnings("WeakerAccess")
public Airtable configure(Configuration config) throws AirtableException {
return configure(config, new GsonObjectMapper());
}


/**
*
* @param config
* @param objectMapper A custom ObjectMapper implementation
* @return
* @throws com.sybit.airtable.exception.AirtableException Missing API-Key or Endpoint
*/
@SuppressWarnings("WeakerAccess")
public Airtable configure(Configuration config, ObjectMapper objectMapper) throws AirtableException {
if(config.getApiKey() == null) {
throw new AirtableException("Missing Airtable API-Key");
}
Expand All @@ -113,22 +153,21 @@ public Airtable configure(Configuration config) throws AirtableException {
setProxy(config.getEndpointUrl());

// Only one time
Unirest.setObjectMapper(new GsonObjectMapper());
Unirest.setObjectMapper(objectMapper);


// Add specific Converter for Date
DateTimeConverter dtConverter = new DateConverter();
ListConverter lConverter = new ListConverter();
MapConverter thConverter = new MapConverter();

lConverter.setListClass(Attachment.class);
thConverter.setMapClass(Thumbnail.class);
dtConverter.setPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");

ConvertUtils.register(dtConverter, Date.class);
ConvertUtils.register(lConverter, List.class);
ConvertUtils.register(thConverter, Map.class);


return this;
}
Expand All @@ -142,8 +181,8 @@ public Airtable configure(Configuration config) throws AirtableException {
private void setProxy(String endpointUrl) {
final String httpProxy = System.getenv("http_proxy");
if(httpProxy != null
&& (endpointUrl.contains("127.0.0.1")
|| endpointUrl.contains("localhost"))) {
&& (endpointUrl.contains("127.0.0.1")
|| endpointUrl.contains("localhost"))) {
LOG.info("Use Proxy: ignored for 'localhost' ann '127.0.0.1'");
Unirest.setProxy(null);
} else if(httpProxy != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,4 @@ public void setMapClass(Class<Thumbnail> aClass) {
public Class getMapClass(){
return this.mapClass;
}

}
1 change: 1 addition & 0 deletions src/test/java/com/sybit/airtable/movies/Actor.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package com.sybit.airtable.movies;



import com.sybit.airtable.movies.*;
import com.google.gson.annotations.SerializedName;
import com.sybit.airtable.vo.Attachment;
Expand Down
1 change: 1 addition & 0 deletions src/test/java/com/sybit/airtable/movies/Movie.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
package com.sybit.airtable.movies;


import com.sybit.airtable.movies.*;
import com.google.gson.annotations.SerializedName;
import com.sybit.airtable.vo.Attachment;
Expand Down