Skip to content
Snippets Groups Projects
Commit c4f2b1b7 authored by Robert Goldmann's avatar Robert Goldmann
Browse files

#157 - added test for PadSettingsSerializer

parent 0b990617
Branches
Tags
No related merge requests found
package de.tobias.playpad.project;
import de.thecodelabs.storage.settings.UserDefaults;
import de.thecodelabs.storage.settings.annotation.Key;
import de.thecodelabs.utils.application.ApplicationUtils;
import de.tobias.playpad.project.api.IProjectSettings;
......@@ -8,14 +9,17 @@ import java.nio.file.Path;
public class ProjectSettings implements IProjectSettings {
public static final int MAX_PAGES;
public static int MAX_PAGES = 10;
static {
Object maxPages = ApplicationUtils.getApplication().getUserDefaults().getData("MAX_PAGES");
if (maxPages != null) {
final UserDefaults userDefaults = ApplicationUtils.getApplication().getUserDefaults();
if(userDefaults != null)
{
Object maxPages = userDefaults.getData("MAX_PAGES");
if(maxPages != null)
{
MAX_PAGES = Integer.parseInt(maxPages.toString());
} else {
MAX_PAGES = 10;
}
}
}
......
package de.tobias.playpad.pad;
import de.tobias.playpad.design.modern.model.ModernCartDesign;
import de.tobias.playpad.project.Project;
import de.tobias.playpad.project.ref.ProjectReference;
import de.tobias.playpad.settings.FadeSettings;
import de.tobias.playpad.tigger.Trigger;
import de.tobias.playpad.tigger.TriggerPoint;
import javafx.util.Duration;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.junit.Test;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import static de.tobias.playpad.pad.PadSerializer.SETTINGS_ELEMENT;
import static org.assertj.core.api.Assertions.assertThat;
public class PadSettingsSerializerTest
{
@Test
public void testSave_General()
{
// arrange
final Document document = DocumentHelper.createDocument();
final Element rootElement = document.addElement(SETTINGS_ELEMENT);
final Project project = new Project(new ProjectReference(UUID.randomUUID(), "TestProject", false));
final Pad pad = new Pad(project, 1, null);
final UUID padUUID = UUID.randomUUID();
final PadSettings padSettings = new PadSettings(pad, padUUID);
padSettings.setVolume(0.5);
padSettings.setLoop(true);
padSettings.setTimeMode(TimeMode.REST);
padSettings.setFade(new FadeSettings(Duration.seconds(1), Duration.seconds(2)));
final Duration expectedWarningDuration = Duration.seconds(3);
padSettings.setWarning(expectedWarningDuration);
final Duration expectedCueInDuration = Duration.seconds(4);
padSettings.setCueIn(expectedCueInDuration);
// act
final PadSettingsSerializer serializer = new PadSettingsSerializer();
serializer.saveElement(rootElement, padSettings);
// assert
assertThat(rootElement.attribute("id").getStringValue()).isEqualTo(padUUID.toString());
assertThat(rootElement.element("Volume").getStringValue()).isEqualTo("0.5");
assertThat(rootElement.element("Loop").getStringValue()).isEqualTo("true");
assertThat(rootElement.element("TimeMode").getStringValue()).isEqualTo(TimeMode.REST.toString());
assertThat(rootElement.element("Fade").getStringValue()).isNotNull();
assertThat(rootElement.element("Warning").getStringValue()).isEqualTo(expectedWarningDuration.toString());
assertThat(rootElement.element("CueIn").getStringValue()).isEqualTo(expectedCueInDuration.toString());
}
}
[
{
"name": "RED1",
"colors": {
"hi": "#ef9a9a",
"low": "#ef5350",
"font": "#000000",
"button": "#000000",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "RED2",
"colors": {
"hi": "#ef5350",
"low": "#e53935",
"font": "#000000",
"button": "#000000",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "RED3",
"colors": {
"hi": "#e53935",
"low": "#c62828",
"font": "#ffffff",
"button": "#ffffff",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "DARK_RED1",
"colors": {
"hi": "#D92349",
"low": "#AD2039",
"font": "#ffffff",
"button": "#ffffff",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "DARK_RED2",
"colors": {
"hi": "#C92349",
"low": "#8D2039",
"font": "#ffffff",
"button": "#ffffff",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "DARK_RED3",
"colors": {
"hi": "#A90329",
"low": "#6D0019",
"font": "#ffffff",
"button": "#ffffff",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "PINK1",
"colors": {
"hi": "#f48fb1",
"low": "#ec407a",
"font": "#000000",
"button": "#000000",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "PINK2",
"colors": {
"hi": "#ec407a",
"low": "#d81b60",
"font": "#000000",
"button": "#000000",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "PINK3",
"colors": {
"hi": "#d81b60",
"low": "#ad1457",
"font": "#ffffff",
"button": "#ffffff",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "PURPLE1",
"colors": {
"hi": "#ce93d8",
"low": "#ab47bc",
"font": "#ffffff",
"button": "#ffffff",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "PURPLE2",
"colors": {
"hi": "#ab47bc",
"low": "#8e24aa",
"font": "#ffffff",
"button": "#ffffff",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "PURPLE3",
"colors": {
"hi": "#8e24aa",
"low": "#6a1b9a",
"font": "#ffffff",
"button": "#ffffff",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "LIGHT_BLUE1",
"colors": {
"hi": "#80deea",
"low": "#26c6da",
"font": "#000000",
"button": "#000000",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "LIGHT_BLUE2",
"colors": {
"hi": "#26c6da",
"low": "#00acc1",
"font": "#ffffff",
"button": "#ffffff",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "LIGHT_BLUE3",
"colors": {
"hi": "#00acc1",
"low": "#00838f",
"font": "#ffffff",
"button": "#ffffff",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "BLUE1",
"colors": {
"hi": "#90caf9",
"low": "#42a5f5",
"font": "#000000",
"button": "#000000",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "BLUE2",
"colors": {
"hi": "#42a5f5",
"low": "#1e88e5",
"font": "#ffffff",
"button": "#ffffff",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "BLUE3",
"colors": {
"hi": "#1e88e5",
"low": "#1565c0",
"font": "#ffffff",
"button": "#ffffff",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "LIGHT_GREEN1",
"colors": {
"hi": "#c5e1a5",
"low": "#9ccc65",
"font": "#000000",
"button": "#000000",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "LIGHT_GREEN2",
"colors": {
"hi": "#9ccc65",
"low": "#7cb342",
"font": "#ffffff",
"button": "#ffffff",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "LIGHT_GREEN3",
"colors": {
"hi": "#7cb342",
"low": "#558b2f",
"font": "#ffffff",
"button": "#ffffff",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "LIME1",
"colors": {
"hi": "#e6ee9c",
"low": "#d4e157",
"font": "#000000",
"button": "#000000",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "LIME2",
"colors": {
"hi": "#d4e157",
"low": "#c0ca33",
"font": "#000000",
"button": "#000000",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "LIME3",
"colors": {
"hi": "#c0ca33",
"low": "#9e9d24",
"font": "#000000",
"button": "#000000",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "YELLOW1",
"colors": {
"hi": "#fff59d",
"low": "#ffee58",
"font": "#000000",
"button": "#000000",
"playbar": {
"background": "#333333",
"track": "#FFFFFF"
}
}
},
{
"name": "YELLOW2",
"colors": {
"hi": "#ffee58",
"low": "#fdd835",
"font": "#000000",
"button": "#000000",
"playbar": {
"background": "#333333",
"track": "#FFFFFF"
}
}
},
{
"name": "YELLOW3",
"colors": {
"hi": "#fdd835",
"low": "#f9a825",
"font": "#000000",
"button": "#000000",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "ORANGE1",
"colors": {
"hi": "#ffcc80",
"low": "#ffa726",
"font": "#000000",
"button": "#000000",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "ORANGE2",
"colors": {
"hi": "#ffa726",
"low": "#fb8c00",
"font": "#000000",
"button": "#000000",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "ORANGE3",
"colors": {
"hi": "#fb8c00",
"low": "#ef6c00",
"font": "#000000",
"button": "#000000",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "GRAY1",
"colors": {
"hi": "#eeeeee",
"low": "#cccccc",
"font": "#000000",
"button": "#000000",
"playbar": {
"background": "#333333",
"track": "#FFFFFF"
}
}
},
{
"name": "GRAY2",
"colors": {
"hi": "#cccccc",
"low": "#aaaaaa",
"font": "#000000",
"button": "#000000",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "GRAY3",
"colors": {
"hi": "#aaaaaa",
"low": "#888888",
"font": "#FFFFFF",
"button": "#FFFFFF",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "GRAY4",
"colors": {
"hi": "#888888",
"low": "#666666",
"font": "#FFFFFF",
"button": "#FFFFFF",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "GRAY5",
"colors": {
"hi": "#666666",
"low": "#444444",
"font": "#FFFFFF",
"button": "#FFFFFF",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
},
{
"name": "GRAY6",
"colors": {
"hi": "#444444",
"low": "#222222",
"font": "#FFFFFF",
"button": "#FFFFFF",
"playbar": {
"background": "#ffffff",
"track": "#333333"
}
}
}
]
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment