Skip to content

Commit

Permalink
Issue #1088 - fix for exception instead fo DebugTokenInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
nbartels committed Aug 25, 2020
1 parent 283a465 commit 410dddf
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
Expand Up @@ -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),
Expand Down
40 changes: 40 additions & 0 deletions 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);
}
}

0 comments on commit 410dddf

Please sign in to comment.