### Question:
QueueMetrics implements MetricsSource { public synchronized static QueueMetrics forQueue(String queueName, Queue parent, boolean enableUserMetrics, Configuration conf) { return forQueue(DefaultMetricsSystem.instance(), queueName, parent, enableUserMetrics, conf); } protected  QueueMetrics(MetricsSystem ms, String queueName, Queue parent, 
	       boolean enableUserMetrics, Configuration conf); synchronized static QueueMetrics forQueue(String queueName, Queue parent,
                               boolean enableUserMetrics,
			       Configuration conf); @Private synchronized static void clearQueueMetrics(); synchronized static QueueMetrics forQueue(MetricsSystem ms, String queueName,
                                      Queue parent, boolean enableUserMetrics,
				      Configuration conf); synchronized QueueMetrics getUserMetrics(String userName); void getMetrics(MetricsCollector collector, boolean all); void submitApp(String user); void submitAppAttempt(String user); void runAppAttempt(ApplicationId appId, String user); void finishAppAttempt(
      ApplicationId appId, boolean isPending, String user); void finishApp(String user, RMAppState rmAppFinalState); void moveAppFrom(AppSchedulingInfo app); void moveAppTo(AppSchedulingInfo app); void setAvailableResourcesToQueue(Resource limit); void setAvailableResourcesToUser(String user, Resource limit); void incrPendingResources(String user, int containers, Resource res); void decrPendingResources(String user, int containers, Resource res); void allocateResources(String user, int containers, Resource res,
      boolean decrPending); void releaseResources(String user, int containers, Resource res); void reserveResource(String user, Resource res); void unreserveResource(String user, Resource res); void incrActiveUsers(); void decrActiveUsers(); void activateApp(String user); void deactivateApp(String user); int getAppsSubmitted(); int getAppsRunning(); int getAppsPending(); int getAppsCompleted(); int getAppsKilled(); int getAppsFailed(); Resource getAllocatedResources(); int getAllocatedMB(); int getAllocatedVirtualCores(); int getAllocatedGpuCores(); int getAllocatedContainers(); int getAvailableMB(); int getAvailableVirtualCores(); int getAvailableGpuCores(); int getPendingMB(); int getPendingVirtualCores(); int getPendingGpuCores(); int getPendingContainers(); int getReservedMB(); int getReservedVirtualCores(); int getReservedGpuCores(); int getReservedContainers(); int getActiveUsers(); int getActiveApps(); MetricsSystem getMetricsSystem();  }### Answer:
@Test public void testCollectAllMetrics() { String queueName = "single"; QueueMetrics.forQueue(ms, queueName, null, false, conf); MetricsSource queueSource = queueSource(ms, queueName); checkApps(queueSource, 0, 0, 0, 0, 0, 0, true); try { checkApps(queueSource, 0, 0, 0, 0, 0, 0, false); Assert.fail(); } catch (AssertionError e) { Assert.assertTrue(e.getMessage().contains( "Expected exactly one metric for name ")); } checkApps(queueSource, 0, 0, 0, 0, 0, 0, true); }