BackendProperties { @Nullable public String getApplicationId() { if (isOnAppEngine()) { String appId = System.getProperty(APP_ID_PROPERTY); if (appId == null) { appId = envReader.getenv(GCLOUD_PROJECT_PROPERTY); } return appId; } else { return null; } } BackendProperties(); @VisibleForTesting  BackendProperties(boolean isAppEngine, EnvReader envReader); boolean isOnAppEngine(); long getProjectNumber(); @Nullable String getProjectId(); @Nullable String getApplicationId();  }
@Test public void testGetApplicationId_appEngine() { assertEquals(APPLICATION_ID, appEngineProperties.getApplicationId()); }
@Test public void testGetApplicationId_flex() { System.clearProperty(BackendProperties.APP_ID_PROPERTY); Mockito.when(envReader.getenv(BackendProperties.GCLOUD_PROJECT_PROPERTY)) .thenReturn(APPLICATION_ID); assertNull(properties.getApplicationId()); }