1 package com.atlassian.plugin.web.descriptors;
2
3 import com.atlassian.plugin.web.model.WebPanel;
4
5 import java.io.IOException;
6 import java.io.StringWriter;
7 import java.io.Writer;
8 import java.util.Map;
9
10
11
12
13
14 public class MockWebPanel implements WebPanel
15 {
16 static final String NOTHING_IN_CONTEXT = "nothing in context";
17
18 public String getHtml(Map<String, Object> context)
19 {
20 StringWriter out = new StringWriter();
21 try
22 {
23 writeHtml(out, context);
24 return out.toString();
25 }
26 catch (IOException e)
27 {
28 throw new RuntimeException(e);
29 }
30 }
31
32 public void writeHtml(Writer writer, Map<String, Object> context) throws IOException
33 {
34 if (!context.isEmpty())
35 {
36 for (Object value : context.values())
37 {
38 writer.write(value.toString());
39 }
40 }
41 else
42 {
43 writer.write(NOTHING_IN_CONTEXT);
44 }
45 }
46 }