From 410dddf73e1ea0333e5193e23b149ca4c57fc068 Mon Sep 17 00:00:00 2001 From: Norbert Bartels Date: Tue, 25 Aug 2020 22:47:12 +0200 Subject: [PATCH] Issue #1088 - fix for exception instead fo DebugTokenInfo --- .../DefaultFacebookExceptionGenerator.java | 4 +- .../restfb/integration/DebugTokenITCase.java | 40 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/test/java/com/restfb/integration/DebugTokenITCase.java diff --git a/src/main/java/com/restfb/exception/generator/DefaultFacebookExceptionGenerator.java b/src/main/java/com/restfb/exception/generator/DefaultFacebookExceptionGenerator.java index 84bc1b614..3b18eca93 100644 --- a/src/main/java/com/restfb/exception/generator/DefaultFacebookExceptionGenerator.java +++ b/src/main/java/com/restfb/exception/generator/DefaultFacebookExceptionGenerator.java @@ -90,7 +90,9 @@ public void throwBatchFacebookResponseStatusExceptionIfNecessary(String json, In JsonObject errorObject = silentlyCreateObjectFromString(json); if (errorObject == null || errorObject.contains(BATCH_ERROR_ATTRIBUTE_NAME) - || errorObject.contains(BATCH_ERROR_DESCRIPTION_ATTRIBUTE_NAME)) + || errorObject.contains(BATCH_ERROR_DESCRIPTION_ATTRIBUTE_NAME) + // not a batch response, if data key is present + || errorObject.contains("data")) return; ExceptionInformation container = new ExceptionInformation(errorObject.getInt(BATCH_ERROR_ATTRIBUTE_NAME, 0), diff --git a/src/test/java/com/restfb/integration/DebugTokenITCase.java b/src/test/java/com/restfb/integration/DebugTokenITCase.java new file mode 100644 index 000000000..ca64c8480 --- /dev/null +++ b/src/test/java/com/restfb/integration/DebugTokenITCase.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2010-2020 Mark Allen, Norbert Bartels. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package com.restfb.integration; + +import com.restfb.DefaultFacebookClient; +import com.restfb.FacebookClient; +import com.restfb.Version; +import com.restfb.integration.base.RestFbIntegrationTestBase; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +public class DebugTokenITCase extends RestFbIntegrationTestBase { + + @Test + public void checkDebugToken() { + DefaultFacebookClient client = new DefaultFacebookClient(getTestSettings().getUserAccessToken(), Version.VERSION_3_1); + FacebookClient.DebugTokenInfo debugTokenInfo = client.debugToken("abc"); + assertNotNull(debugTokenInfo); + } +}