### Question:
NavInflater { @SuppressLint("ResourceType") @NonNull public NavGraph inflate(@NavigationRes int graphResId) { Resources res = mContext.getResources(); XmlResourceParser parser = res.getXml(graphResId); final AttributeSet attrs = Xml.asAttributeSet(parser); try { int type; while ((type = parser.next()) != XmlPullParser.START_TAG && type != XmlPullParser.END_DOCUMENT) { } if (type != XmlPullParser.START_TAG) { throw new XmlPullParserException("No start tag found"); } String rootElement = parser.getName(); NavDestination destination = inflate(res, parser, attrs); if (!(destination instanceof NavGraph)) { throw new IllegalArgumentException("Root element <" + rootElement + ">" + " did not inflate into a NavGraph"); } return (NavGraph) destination; } catch (Exception e) { throw new RuntimeException("Exception inflating " + res.getResourceName(graphResId) + " line " + parser.getLineNumber(), e); } finally { parser.close(); } } NavInflater(@NonNull Context context, @NonNull NavigatorProvider navigatorProvider); @Nullable NavGraph inflateMetadataGraph(); @SuppressLint("ResourceType") @NonNull NavGraph inflate(@NavigationRes int graphResId); @SuppressWarnings("WeakerAccess")
    static final String METADATA_KEY_GRAPH; }### Answer:
@Test public void testInflateSimple() { Context context = InstrumentationRegistry.getTargetContext(); NavInflater navInflater = new NavInflater(context, new TestNavigatorProvider(context)); NavGraph graph = navInflater.inflate(R.navigation.nav_simple); assertThat(graph, is(notNullValue(NavGraph.class))); assertThat(graph.getStartDestination(), is(R.id.start_test)); }
@Test public void testInflateDeepLinkWithApplicationId() { Context context = InstrumentationRegistry.getTargetContext(); NavInflater navInflater = new NavInflater(context, new TestNavigatorProvider(context)); NavGraph graph = navInflater.inflate(R.navigation.nav_simple); assertThat(graph, is(notNullValue(NavGraph.class))); Uri expectedUri = Uri.parse("android-app: + mInstrumentation.getTargetContext().getPackageName() + "/test"); Pair<NavDestination, Bundle> result = graph.matchDeepLink(expectedUri); assertThat(result, is(notNullValue())); assert result != null; assertThat(result.first, is(notNullValue(NavDestination.class))); assertThat(result.first.getId(), is(R.id.second_test)); }