This repository has been archived by the owner on Jun 9, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Falling back on 1.x settings if no 2.x settings
- Loading branch information
1 parent
7e95606
commit e8ecb22
Showing
6 changed files
with
85 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/test/java/se/bjurr/prnfb/settings/SettingsStorageTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package se.bjurr.prnfb.settings; | ||
|
||
import static com.google.common.collect.Lists.newArrayList; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
import static se.bjurr.prnfb.settings.SettingsStorage.STORAGE_KEY; | ||
import static se.bjurr.prnfb.settings.SettingsStorage.STORAGE_KEY_PRNFS; | ||
import static se.bjurr.prnfb.settings.SettingsStorage.getSettingsAsFormValues; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import se.bjurr.prnfb.admin.AdminFormValues; | ||
|
||
import com.atlassian.sal.api.pluginsettings.PluginSettings; | ||
import com.google.common.collect.ImmutableMap; | ||
import com.google.gson.Gson; | ||
|
||
public class SettingsStorageTest { | ||
|
||
private String prnfs; | ||
private String prnfb; | ||
private PluginSettings settings; | ||
|
||
@Before | ||
public void before() { | ||
AdminFormValues prnfs = new AdminFormValues(); | ||
prnfs.add(ImmutableMap.<String, String> builder().put("key", "PRNFS").build()); | ||
this.prnfs = new Gson().toJson(prnfs); | ||
AdminFormValues prnfb = new AdminFormValues(); | ||
prnfb.add(ImmutableMap.<String, String> builder().put("key", "PRNFB").build()); | ||
this.prnfb = new Gson().toJson(prnfb); | ||
settings = mock(PluginSettings.class); | ||
} | ||
|
||
@Test | ||
public void testThatPrnfsSettingsAreUsedIfAvailableAnNoPrnfbSettingsAvailable() { | ||
when(settings.get(STORAGE_KEY_PRNFS)).thenReturn(newArrayList(prnfs)); | ||
assertEquals("PRNFS", getSettingsAsFormValues(settings).get(0).get(0).get("key")); | ||
} | ||
|
||
@Test | ||
public void testThatPrnfbSettingsAreUsedIfAvailable() { | ||
when(settings.get(STORAGE_KEY)).thenReturn(newArrayList(prnfb)); | ||
assertEquals("PRNFB", getSettingsAsFormValues(settings).get(0).get(0).get("key")); | ||
} | ||
|
||
@Test | ||
public void testThatPrnfbSettingsAreUsedIfAvailableEvenIfPrnfsAreAvailable() { | ||
when(settings.get(STORAGE_KEY)).thenReturn(newArrayList(prnfb)); | ||
when(settings.get(STORAGE_KEY_PRNFS)).thenReturn(newArrayList(prnfs)); | ||
assertEquals("PRNFB", getSettingsAsFormValues(settings).get(0).get(0).get("key")); | ||
} | ||
|
||
} |