-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
105 additions
and
2 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
13 changes: 13 additions & 0 deletions
13
src/main/java/ru/colibri/ui/core/exception/PropertyNotFoundException.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,13 @@ | ||
package ru.colibri.ui.core.exception; | ||
|
||
import static java.lang.String.format; | ||
|
||
public class PropertyNotFoundException extends IllegalArgumentException { | ||
public PropertyNotFoundException(String message) { | ||
super(message); | ||
} | ||
|
||
public PropertyNotFoundException(String propertyName, String propertyPath) { | ||
this(format("Property %s not found on file: %s", propertyName, propertyPath)); | ||
} | ||
} |
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
16 changes: 16 additions & 0 deletions
16
src/test/java/ru/colibri/ui/settings/loaders/AbsSettingsLoaderFake.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,16 @@ | ||
package ru.colibri.ui.settings.loaders; | ||
|
||
import ru.colibri.ui.core.settings.AppSettings; | ||
import ru.colibri.ui.core.settings.DriversSettings; | ||
|
||
public class AbsSettingsLoaderFake extends AbsSettingsLoader { | ||
@Override | ||
public AppSettings loadAppSettings(String userName) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public DriversSettings loadDriverSettings(String platformName) { | ||
return null; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/test/java/ru/colibri/ui/settings/loaders/AbsSettingsLoaderTest.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,51 @@ | ||
package ru.colibri.ui.settings.loaders; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
import ru.colibri.ui.core.exception.PropertyNotFoundException; | ||
import ru.colibri.ui.core.settings.TestSettings; | ||
|
||
import static java.lang.String.format; | ||
|
||
@RunWith(SpringJUnit4ClassRunner.class) | ||
@ContextConfiguration(classes = {SettingsLoaderConfig.class}) | ||
public class AbsSettingsLoaderTest { | ||
|
||
private static final String TEST_TYPE_FILTER = "src/test/resources/planTestCycle/testCycle.properties"; | ||
|
||
@Autowired | ||
private ISettingsLoader settingsLoader; | ||
|
||
@Test | ||
public void loadTestSettings() throws Exception { | ||
TestSettings testSettings = settingsLoader.loadTestSettings("actual.property"); | ||
Assert.assertEquals(testSettings.getFlagsMetaFilters().size(), 2); | ||
Assert.assertEquals(testSettings.getFlagsMetaFilters().get(0), "hello"); | ||
} | ||
|
||
|
||
@Test(expected = PropertyNotFoundException.class) | ||
public void loadTestSettingsBad() throws Exception { | ||
settingsLoader.loadTestSettings("bad.property"); | ||
} | ||
|
||
@Test | ||
public void loadTestSettingsBadWithText() throws Exception { | ||
String propertyName = "bad.property"; | ||
try { | ||
settingsLoader.loadTestSettings(propertyName); | ||
} catch (PropertyNotFoundException e) { | ||
Assert.assertEquals(e.getMessage(), format("Property %s not found on file: %s", propertyName, TEST_TYPE_FILTER)); | ||
} | ||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void loadTestSettingsEmpty() throws Exception { | ||
settingsLoader.loadTestSettings("empty.property"); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
src/test/java/ru/colibri/ui/settings/loaders/SettingsLoaderConfig.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,15 @@ | ||
package ru.colibri.ui.settings.loaders; | ||
|
||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class SettingsLoaderConfig { | ||
|
||
@Bean | ||
ISettingsLoader loader() { | ||
return new AbsSettingsLoaderFake(); | ||
} | ||
|
||
} |
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,2 @@ | ||
actual.property=hello,world | ||
bad.property= |