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
50 changes: 34 additions & 16 deletions src/itest/java/com/sybit/airtable/TableDestroyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,54 @@
import com.sybit.airtable.exception.AirtableException;
import com.sybit.airtable.movies.Actor;
import com.sybit.airtable.mock.WireMockBaseTest;
import java.util.List;
import org.apache.http.client.HttpResponseException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Ignore;
import org.junit.Test;

/**
*
* @author fzr
*/
public class TableDestroyTest extends WireMockBaseTest {




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

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

actorTable.destroy("recapJ3Js8AEwt0Bf");


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

}

/**
* No Condition found under which Airtable returns false for deleting an Object. Either it doesent find it, which results in a 404 HTTP Exception
* Or something else is wrong with the Syntax, which results in another Exception.
* Therefore this test is Ignored as long as we dont have an Example of a failed delete from Airtable.
* @throws AirtableException
*/

@Test (expected = AirtableException.class)
public void testDestroyMovieException() throws AirtableException{

@Ignore
@Test
public void testDestroyMovieFailure() throws AirtableException {

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

actorTable.destroy("not succesfull");

boolean destroyed = actorTable.destroy("failed");
assertFalse(destroyed);
}


@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");
}

}
4 changes: 4 additions & 0 deletions src/itest/resources/__files/body-ActorDeleteFailed.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"deleted": false,
"id": "recapJ3Js8AEwt0BfF"
}
10 changes: 10 additions & 0 deletions src/itest/resources/mappings/mapping-ActorDeleteFailed.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"request" : {
"url" : "/v0/appe9941ff07fffcc/Actors/failed",
"method" : "DELETE"
},
"response" : {
"status" : 200,
"bodyFileName" : "/body-ActorDeleteFailed.json"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
},
"response" : {
"status" : 200,
"bodyFileName" : "/body-ActorDelete.json"
"bodyFileName" : "/body-ActorDeleteSucess.json"
}
}
Loading