1 package com.atlassian.sal.core.pluginsettings;
2
3 import com.atlassian.sal.api.pluginsettings.PluginSettings;
4 import org.junit.Before;
5 import org.junit.Test;
6 import org.mockito.Mock;
7 import org.mockito.MockitoAnnotations;
8
9 import static org.junit.Assert.assertSame;
10 import static org.mockito.Mockito.when;
11
12 public class TestPrefixedPluginSettingsDelegate {
13 @Mock
14 private PluginSettings target;
15 private PluginSettings prefixedPluginSettings;
16
17 private static final Object VALUE = new Object();
18
19 @Before
20 public void initMocks() {
21 MockitoAnnotations.initMocks(this);
22 prefixedPluginSettings = new PrefixedPluginSettingsDelegate("prefix", target);
23 }
24
25 @Test
26 public void testGet() {
27 when(target.get("prefixkey")).thenReturn(VALUE);
28 assertSame(VALUE, prefixedPluginSettings.get("key"));
29 }
30
31 @Test
32 public void testPut() {
33 when(target.put("prefixkey", VALUE)).thenReturn(VALUE);
34 assertSame(VALUE, prefixedPluginSettings.put("key", VALUE));
35 }
36
37 @Test
38 public void testRemove() {
39 when(target.remove("prefixkey")).thenReturn(VALUE);
40 assertSame(VALUE, prefixedPluginSettings.remove("key"));
41 }
42 }