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
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: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ dependencies {

testCompile group: 'junit', name: 'junit', version:'4.12'
testCompile group: 'commons-io', name: 'commons-io', version:'2.5'
testCompile group: 'com.github.tomakehurst', name: 'wiremock', version:'2.5.1'
testCompile group: 'com.github.tomakehurst', name: 'wiremock', version:'2.8.0'
testCompile group: 'org.slf4j', name: 'slf4j-jdk14', version:'1.7.25'

codacy group: 'com.codacy', name: 'codacy-coverage-reporter', version: '1.0.13'
Expand Down
28 changes: 11 additions & 17 deletions src/itest/java/com/sybit/airtable/TableConverterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,13 @@ public class TableConverterTest extends WireMockBaseTest {
@Test
public void testConvertMovie() throws AirtableException, HttpResponseException {

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

Table<Movie> movieTable = base.table("Movies", Movie.class);
Movie movie = movieTable.find("rec6733da527dd0f1");
Movie movie = movieTable.find("recFj9J78MLtiFFMz");
assertNotNull(movie);

assertEquals(movie.getId(),"rec6733da527dd0f1");
assertEquals(movie.getId(),"recFj9J78MLtiFFMz");
assertEquals(movie.getName(),"The Godfather");
assertEquals(movie.getDescription(),"The Godfather is a 1972 American crime film film directed by Francis Ford Coppola and produced by Albert S. Ruddy and based on Mario Puzo's best-selli...");
assertEquals(movie.getPhotos().size(),2);
assertEquals(movie.getDirector().size(),1);
assertEquals(movie.getActors().size(),2);
Expand All @@ -53,10 +51,8 @@ public void testConvertMovie() throws AirtableException, HttpResponseException {
public void testConvertAttachement() throws AirtableException, HttpResponseException {


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

Table<Movie> movieTable = base.table("Movies", Movie.class);
Movie movie = movieTable.find("rec6733da527dd0f1");
Movie movie = movieTable.find("recFj9J78MLtiFFMz");
assertNotNull(movie);

assertEquals(movie.getPhotos().size(),2);
Expand All @@ -66,31 +62,29 @@ public void testConvertAttachement() throws AirtableException, HttpResponseExcep
Attachment photo2 = movie.getPhotos().get(0);
assertNotNull(photo2);

assertEquals(photo1.getId(),"att6dba4af5786df1");
assertEquals(photo1.getUrl(),"https://www.filepicker.io/api/file/akW7wUX7QM66a2hjxb9k");
assertEquals(photo1.getFilename(),"220px-TheGodfatherAlPacinoMarlonBrando.jpg");
assertEquals(photo1.getSize(),16420.0,0);
assertEquals(photo1.getId(),"attk3WY5B28GVcFGU");
assertEquals(photo1.getUrl(),"https://dl.airtable.com/9UhUUeAtSym1PzBdA0q0_AlPacinoandMarlonBrando.jpg");
assertEquals(photo1.getFilename(),"AlPacinoandMarlonBrando.jpg");
assertEquals(photo1.getSize(),35698,0);
assertEquals(photo1.getType(),"image/jpeg");
assertEquals(photo1.getThumbnails().size(),2);

}

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

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


Table<Movie> movieTable = base.table("Movies", Movie.class);
Movie movie = movieTable.find("rec6733da527dd0f1");
Movie movie = movieTable.find("recFj9J78MLtiFFMz");
assertNotNull(movie);

assertEquals(movie.getPhotos().get(0).getThumbnails().size(),2);
assertEquals(movie.getPhotos().get(1).getThumbnails().size(),2);
Map<String, Thumbnail> thumbnails = movie.getPhotos().get(1).getThumbnails();
Thumbnail thumb = thumbnails.get("small");
assertEquals(thumb.getUrl(),"https://dl.airtable.com/MbdRAn4ZQLuNyUqrHONp_small_Lighthouse.jpg");
assertEquals(thumb.getUrl(),"https://dl.airtable.com/rlQ8MyQ4RuqN7rT03ALq_small_The%20Godfather%20poster.jpg");
assertEquals(thumb.getHeight(),36.0, 0);
assertEquals(thumb.getWidth(),48.0, 0);
assertEquals(thumb.getWidth(),24.0, 0);

}

Expand Down
33 changes: 11 additions & 22 deletions src/itest/java/com/sybit/airtable/TableCreateRecordTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public class TableCreateRecordTest extends WireMockBaseTest {
@Test(expected = AirtableException.class)
public void createMovieWithPhotoIdTest() throws AirtableException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {

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

Table<Movie> movieTable = base.table("Movies", Movie.class);
Movie newMovie = new Movie();
Expand All @@ -51,9 +50,7 @@ public void createMovieWithPhotoIdTest() throws AirtableException, IllegalAccess

@Test(expected = AirtableException.class)
public void createMovieWithIdTest() throws AirtableException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, InstantiationException, NoSuchFieldException{

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


Table<Movie> movieTable = base.table("Movies", Movie.class);
Movie newMovie = new Movie();
newMovie.setName("Neuer Film");
Expand All @@ -64,9 +61,7 @@ public void createMovieWithIdTest() throws AirtableException, IllegalAccessExcep

@Test(expected = AirtableException.class)
public void createMovieWithCreatedTimeTest() throws AirtableException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, InstantiationException, NoSuchFieldException{

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


Table<Movie> movieTable = base.table("Movies", Movie.class);
Movie newMovie = new Movie();
newMovie.setName("Neuer Film");
Expand All @@ -77,23 +72,19 @@ public void createMovieWithCreatedTimeTest() throws AirtableException, IllegalAc

@Test
public void createActorTest() throws AirtableException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, InstantiationException, NoSuchFieldException{

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


Table<Actor> actorTable = base.table("Actors", Actor.class);
Actor newActor = new Actor();
newActor.setName("Neuer Actor");
Actor test = actorTable.create(newActor);
assertEquals(test.getName(),newActor.getName());
assertEquals(test.getId(),"rec123456789");

assertNotNull(test.getId());
}

@Test
public void createMovieWithAttachementTest() throws AirtableException, IllegalAccessException, NoSuchMethodException, NoSuchMethodException, InstantiationException, InvocationTargetException, NoSuchFieldException {

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


Table<Movie> movieTable = base.table("Movies", Movie.class);
Movie newMovie = new Movie();

Expand Down Expand Up @@ -121,20 +112,18 @@ public void createMovieWithAttachementTest() throws AirtableException, IllegalAc

@Test
public void createMovieTest() throws AirtableException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, InstantiationException, NoSuchFieldException{

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


Table<Movie> movieTable = base.table("Movies", Movie.class);
Movie newMovie = new Movie();

newMovie.setName("Neuer Film");
newMovie.setDescription("Irgendwas");
List<String> director = new ArrayList<>();
director.add("recfaf64fe0db19a9");
director.add("recPxOZblV8yJU4mY");
newMovie.setDirector(director);
List<String> actors = new ArrayList<>();
actors.add("recc8841a14245b0b");
actors.add("rec514228ed76ced1");
actors.add("recEtUIW6FWtbEDKz");
actors.add("recInYFZ1DQpeCuSz");
newMovie.setActors(actors);
List<String> genre = new ArrayList<>();
genre.add("Drama");
Expand All @@ -146,7 +135,7 @@ public void createMovieTest() throws AirtableException, IllegalAccessException,
assertEquals(newMovie.getActors(),test.getActors());
assertEquals(newMovie.getGenre(),test.getGenre());
assertEquals(newMovie.getDescription(),test.getDescription());
assertEquals("rec987654321",test.getId());
assertNotNull(test.getId());
assertNotNull(test.getCreatedTime());


Expand Down
6 changes: 1 addition & 5 deletions src/itest/java/com/sybit/airtable/TableDestroyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ public class TableDestroyTest extends WireMockBaseTest {
@Test
public void testDestroyMovie() throws AirtableException, HttpResponseException {

Base base = airtable.base("appe9941ff07fffcc");
Table<Actor> actorTable = base.table("Actors", Actor.class);

boolean destroyed = actorTable.destroy("recapJ3Js8AEwt0Bf");
boolean destroyed = actorTable.destroy("recAt6z10EYD6NtEH");
assertTrue(destroyed);

}
Expand All @@ -44,7 +43,6 @@ public void testDestroyMovie() throws AirtableException, HttpResponseException {
@Test
public void testDestroyMovieFailure() throws AirtableException {

Base base = airtable.base("appe9941ff07fffcc");
Table<Actor> actorTable = base.table("Actors", Actor.class);

boolean destroyed = actorTable.destroy("failed");
Expand All @@ -54,9 +52,7 @@ public void testDestroyMovieFailure() throws AirtableException {
@Test(expected = AirtableException.class)
public void testDestroyMovieException() throws AirtableException {

Base base = airtable.base("appe9941ff07fffcc");
Table<Actor> actorTable = base.table("Actors", Actor.class);

boolean destroyed = actorTable.destroy("not succesfull");
}

Expand Down
8 changes: 2 additions & 6 deletions src/itest/java/com/sybit/airtable/TableFindTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,16 @@ public class TableFindTest extends WireMockBaseTest {
@Test
public void testFind() throws AirtableException, HttpResponseException {

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

Table<Actor> actorTable = base.table("Actors", Actor.class);
Actor actor = actorTable.find("rec514228ed76ced1");
Actor actor = actorTable.find("recEtUIW6FWtbEDKz");
assertNotNull(actor);
assertEquals("rec514228ed76ced1", actor.getId());
assertEquals("recEtUIW6FWtbEDKz", actor.getId());
assertEquals("Marlon Brando", actor.getName());
}

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

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

Table<Actor> actorTable = base.table("Actors", Actor.class);
Actor actor = actorTable.find("notexistend");
assertNotNull(actor);
Expand Down
Loading