@Test public void buildGraphQL_throwsAnExceptionWhenTheQueryCannotBeRead() throws InvalidArgumentException { Resources resources = mock(Resources.class); doThrow(new NotFoundException("Not found")).when(resources).openRawResource(anyInt()); Context context = mock(Context.class); when(context.getResources()).thenReturn(resources); try { new CardBuilder().buildGraphQL(context, Authorization.fromString(TOKENIZATION_KEY)); fail("Expected exception"); } catch (BraintreeException e) { assertEquals("Unable to read GraphQL query", e.getMessage()); assertEquals("Not found", e.getCause().getMessage()); } }