Resource { public String buildHTMLString(String location) { final StringBuilder builder = new StringBuilder(); if (this.getType() == ResourceType.JAVASCRIPT_FILE) { builder.append("<script type=\"text/javascript\" src=\"").append(location).append("/").append(this.getContent()).append("\">"); } else if (this.getType() == ResourceType.SCRIPT) { builder.append("<script type=\"text/javascript\">").append(this.getContent()).append("</script>"); } else if (this.getType() == ResourceType.CSS_FILE) { builder.append("<link rel=\"stylesheet\" href=\"").append(location).append("/").append(this.getContent()).append("\">"); } else if (this.getType() == ResourceType.CSS) { builder.append("<style>").append(this.getContent()).append("</style>"); } return builder.toString(); } Resource(ResourceType type, String content);  Resource(final ResourceType type, final String content, final ResourceLocation location, final URL resourceUrl); String getContent(); void setContent(String content); ResourceType getType(); void setType(ResourceType type); ResourceLocation getLocation(); void setLocation(ResourceLocation location); URL getResourceUrl(); void setResourceUrl(URL resourceUrl); String buildHTMLString(String location); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void testJavaScriptFile() { final Resource resource = new Resource(ResourceType.JAVASCRIPT_FILE, "somewhere/file.js"); final String expected = "<script type=\"text/javascript\" src=\"base/path/somewhere/file.js\">"; assertEquals(expected, resource.buildHTMLString("base/path")); }
@Test public void testCSSFile() { final Resource resource = new Resource(ResourceType.CSS_FILE, "somewhere/file.css"); final String expected = "<link rel=\"stylesheet\" href=\"base/path/somewhere/file.css\">"; assertEquals(expected, resource.buildHTMLString("base/path")); }
@Test public void testScript() { final Resource resource = new Resource(ResourceType.SCRIPT, "var s = 42;"); final String expected = "<script type=\"text/javascript\">var s = 42;</script>"; assertEquals(expected, resource.buildHTMLString("base/path")); }
@Test public void testStyle() { final Resource resource = new Resource(ResourceType.CSS, "h1 {\n\tcolor: red;\n}"); final String expected = "<style>h1 {\n\tcolor: red;\n}</style>"; assertEquals(expected, resource.buildHTMLString("base/path")); }