### Question:
MonitoredResourceBuilder { String matchAttribute(String text, String key) { String regex = String.format("\"%s\" : \"(.+?)\"", key); Pattern p = Pattern.compile(regex); Matcher m = p.matcher(text); return m.find() ? m.group(1) : ""; } MonitoredResourceBuilder(); String determineProjectName(String defaultProjectName); MonitoredResource build();  }### Answer:
@Test public void testMatchAttribute() { String text = "{\n" + " \"version\" : \"2016-08-01\",\n" + " \"instanceId\" : \"the-instance\",\n" + " \"region\" : \"us-east-1\"\n" + "}"; Assert.assertEquals("the-instance", builder.matchAttribute(text, "instanceId")); Assert.assertEquals("us-east-1", builder.matchAttribute(text, "region")); Assert.assertEquals("", builder.matchAttribute(text, "notFound")); }