Minor: extract several assert methods
This commit is contained in:
@@ -93,12 +93,12 @@ public class ConfigureKotlinTest extends PlatformTestCase {
|
|||||||
for (Module module : modules) {
|
for (Module module : modules) {
|
||||||
if (module.getName().equals("module1")) {
|
if (module.getName().equals("module1")) {
|
||||||
configure(module, KotlinWithLibraryConfigurator.FileState.DO_NOT_COPY, LibraryState.NEW_LIBRARY, JAVA_CONFIGURATOR);
|
configure(module, KotlinWithLibraryConfigurator.FileState.DO_NOT_COPY, LibraryState.NEW_LIBRARY, JAVA_CONFIGURATOR);
|
||||||
assertTrue("Module " + module.getName() + " should be configured", JAVA_CONFIGURATOR.isConfigured(module));
|
assertConfigured(module, JAVA_CONFIGURATOR);
|
||||||
}
|
}
|
||||||
else if (module.getName().equals("module2")) {
|
else if (module.getName().equals("module2")) {
|
||||||
assertFalse("Module " + module.getName() + " should not be configured", JAVA_CONFIGURATOR.isConfigured(module));
|
assertNotConfigured(module, JAVA_CONFIGURATOR);
|
||||||
configure(module, FileState.EXISTS, LibraryState.LIBRARY, JAVA_CONFIGURATOR);
|
configure(module, FileState.EXISTS, LibraryState.LIBRARY, JAVA_CONFIGURATOR);
|
||||||
assertTrue("Module " + module.getName() + " should be configured", JAVA_CONFIGURATOR.isConfigured(module));
|
assertConfigured(module, JAVA_CONFIGURATOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,11 +106,9 @@ public class ConfigureKotlinTest extends PlatformTestCase {
|
|||||||
public void testLibraryNonDefault_libExistInDefault() throws IOException {
|
public void testLibraryNonDefault_libExistInDefault() throws IOException {
|
||||||
Module module = getModule();
|
Module module = getModule();
|
||||||
|
|
||||||
assertFalse("Module " + module.getName() + " should not be configured", JAVA_CONFIGURATOR.isConfigured(module));
|
assertNotConfigured(module, JAVA_CONFIGURATOR);
|
||||||
JAVA_CONFIGURATOR.configure(myProject);
|
JAVA_CONFIGURATOR.configure(myProject);
|
||||||
assertTrue("Module " + module.getName() + " should be configured", JAVA_CONFIGURATOR.isConfigured(getModule()));
|
assertProperlyConfigured(module, JAVA_CONFIGURATOR);
|
||||||
assertFalse("Module " + getModule().getName() + " should not be configured as JavaScript Module",
|
|
||||||
JS_CONFIGURATOR.isConfigured(getModule()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testNewLibrary_jarExists_js() {
|
public void testNewLibrary_jarExists_js() {
|
||||||
@@ -149,22 +147,19 @@ public class ConfigureKotlinTest extends PlatformTestCase {
|
|||||||
|
|
||||||
private void doTestOneJavaModule(@NotNull FileState jarState, @NotNull LibraryState libraryState) {
|
private void doTestOneJavaModule(@NotNull FileState jarState, @NotNull LibraryState libraryState) {
|
||||||
doTestOneModule(jarState, libraryState, JAVA_CONFIGURATOR);
|
doTestOneModule(jarState, libraryState, JAVA_CONFIGURATOR);
|
||||||
assertFalse("Module " + getModule().getName() + " should not be configured as JavaScript Module",
|
|
||||||
JS_CONFIGURATOR.isConfigured(getModule()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doTestOneJsModule(@NotNull FileState jarState, @NotNull LibraryState libraryState) {
|
private void doTestOneJsModule(@NotNull FileState jarState, @NotNull LibraryState libraryState) {
|
||||||
doTestOneModule(jarState, libraryState, JS_CONFIGURATOR);
|
doTestOneModule(jarState, libraryState, JS_CONFIGURATOR);
|
||||||
assertFalse("Module " + getModule().getName() + " should not be configured as Java Module",
|
|
||||||
JAVA_CONFIGURATOR.isConfigured(getModule()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doTestOneModule(@NotNull FileState jarState, @NotNull LibraryState libraryState, @NotNull KotlinWithLibraryConfigurator configurator) {
|
private void doTestOneModule(@NotNull FileState jarState, @NotNull LibraryState libraryState, @NotNull KotlinWithLibraryConfigurator configurator) {
|
||||||
Module module = getModule();
|
Module module = getModule();
|
||||||
assertEquals("Library state loaded from project files should be " + libraryState, libraryState, configurator.getLibraryState(module.getProject()));
|
assertEquals("Library state loaded from project files should be " + libraryState, libraryState, configurator.getLibraryState(module.getProject()));
|
||||||
assertFalse("Module " + module.getName() + " should not be configured", configurator.isConfigured(module));
|
|
||||||
|
assertNotConfigured(module, configurator);
|
||||||
configure(module, jarState, libraryState, configurator);
|
configure(module, jarState, libraryState, configurator);
|
||||||
assertTrue("Module " + module.getName() + " should be configured", configurator.isConfigured(getModule()));
|
assertProperlyConfigured(module, configurator);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void configure(
|
private static void configure(
|
||||||
@@ -263,4 +258,28 @@ public class ConfigureKotlinTest extends PlatformTestCase {
|
|||||||
@Override
|
@Override
|
||||||
protected void setUpModule() {
|
protected void setUpModule() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void assertNotConfigured(Module module, KotlinWithLibraryConfigurator configurator) {
|
||||||
|
assertFalse(
|
||||||
|
String.format("Module %s should not be configured as %s Module", module.getName(), configurator.getPresentableText()),
|
||||||
|
configurator.isConfigured(module));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void assertConfigured(Module module, KotlinWithLibraryConfigurator configurator) {
|
||||||
|
assertTrue(String.format("Module %s should be configured with configurator '%s'", module.getName(),
|
||||||
|
configurator.getPresentableText()),
|
||||||
|
configurator.isConfigured(module));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void assertProperlyConfigured(Module module, KotlinWithLibraryConfigurator configurator) {
|
||||||
|
assertConfigured(module, configurator);
|
||||||
|
assertNotConfigured(module, getOppositeConfigurator(configurator));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static KotlinWithLibraryConfigurator getOppositeConfigurator(KotlinWithLibraryConfigurator configurator) {
|
||||||
|
if (configurator == JAVA_CONFIGURATOR) return JS_CONFIGURATOR;
|
||||||
|
if (configurator == JS_CONFIGURATOR) return JAVA_CONFIGURATOR;
|
||||||
|
|
||||||
|
throw new IllegalArgumentException("Only JS_CONFIGURATOR and JAVA_CONFIGURATOR are supported");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user