Skip to content

Commit

Permalink
Convert core-web tests to kotlin and remove mockito/mockito-kotlin, a…
Browse files Browse the repository at this point in the history
…ssertj
  • Loading branch information
ursjoss committed May 4, 2020
1 parent 78375bf commit 8fcc8f0
Show file tree
Hide file tree
Showing 253 changed files with 11,863 additions and 13,466 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ NOTE: References to user stories are in the form Iteration/Story-Number.

.Removed
- apache-io, commons-lang3, commons-collections4, jool
- {url-issues}177[#177] Removed mockito, mockito-kotlin, assertj. Converted all tests to kotlin.

.Fixed

Expand Down
9 changes: 0 additions & 9 deletions buildSrc/src/main/kotlin/Lib.kt
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,6 @@ object Lib {

fun junit5(module: String = "") = Dep("org.junit.jupiter", "junit-jupiter${if (module.isNotBlank()) "-$module" else ""}", junit5Version)

@Deprecated("Replace with mockk")
fun mockito3(module: String) = Dep("org.mockito", "mockito-$module", mockitoVersion)

@Deprecated("Replace with mockk")
fun mockitoKotlin() = Dep("com.nhaarman.mockitokotlin2", "mockito-kotlin", mockitoKotlinVersion)

@Deprecated("Replace with kluent")
fun assertj() = Dep("org.assertj", "assertj-core")

fun testcontainers(module: String) = Dep("org.testcontainers", module, testcontainersVersion)
fun equalsverifier() = Dep("nl.jqno.equalsverifier", "equalsverifier", equalsverifierVersion)
fun spek(module: String) = Dep("org.spekframework.spek2", "spek-$module", spekVersion)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected Navbar getNavBar() {
return navbar;
}

@NotNull
@Nullable
public NotificationPanel getFeedbackPanel() {
return feedbackPanel;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package ch.difty.scipamato.core.persistence

import io.mockk.mockk

inline fun <reified T : Any> mock(): T = mockk<T>()!!
inline fun <reified T : Any> mock(): T = mockk<T>()
5 changes: 0 additions & 5 deletions core/core-web/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ dependencies {
testImplementation(Lib.validationApi())
testImplementation(Lib.lombok())
testAnnotationProcessor(Lib.lombok())

testImplementation(Lib.assertj())
testImplementation(Lib.mockito3("core"))
testImplementation(Lib.mockitoKotlin())
testImplementation(Lib.mockito3("junit-jupiter"))
}

idea {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class CodeClassEditPage extends DefinitionEditPage<CodeClassDefinition, C
super(model, callingPageRef);
}

@Nullable
@NotNull
@Override
protected CodeClassDefinition persistModel() {
return service.saveOrUpdate(getModelObject());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ch.difty.scipamato.core.web.common;

import de.agilecoders.wicket.core.markup.html.bootstrap.common.NotificationPanel;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.model.IModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
Expand Down Expand Up @@ -83,7 +84,9 @@ protected void implSpecificOnInitialize() {
* too much information.
*/
protected void tuneDownFeedbackMessages() {
getFeedbackPanel().setMaxMessages(1);
final NotificationPanel panel = getFeedbackPanel();
if (panel != null)
panel.setMaxMessages(1);
}

/**
Expand All @@ -92,6 +95,8 @@ protected void tuneDownFeedbackMessages() {
* indicated to the user in full detail.
*/
protected void resetFeedbackMessages() {
getFeedbackPanel().setMaxMessages(Integer.MAX_VALUE);
final NotificationPanel panel = getFeedbackPanel();
if (panel != null)
panel.setMaxMessages(Integer.MAX_VALUE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,20 +174,23 @@ class SearchOrderSelectorPanel internal constructor(id: String, model: IModel<Se
}

private fun saveOrUpdate() {
searchOrderService.saveOrUpdate(modelObject!!)?.let {
form.defaultModelObject = it
modelObject?.let { mo ->
searchOrderService.saveOrUpdate(mo)?.let { saved ->
form.defaultModelObject = saved
}
}
}

private val isModelSelected: Boolean
get() = modelObject?.id != null

private val isUserEntitled: Boolean
get() = modelObject != null &&
get() = modelObject?.let { mo ->
if (isViewMode)
!modelObject!!.isGlobal && modelObject!!.owner == activeUser.id
!mo.isGlobal && mo.owner == activeUser.id
else
modelObject!!.owner == activeUser.id
mo.owner == activeUser.id
} ?: false

private fun hasExclusions(): Boolean =
isModelSelected && modelObject!!.excludedPaperIds.isNotEmpty()
Expand Down Expand Up @@ -219,7 +222,8 @@ class SearchOrderSelectorPanel internal constructor(id: String, model: IModel<Se
showExcluded = object : AjaxCheckBox(id) {
override fun onConfigure() {
super.onConfigure()
if (isVisible && !hasExclusions()) modelObject = false
if (isVisible && !hasExclusions() && modelObject != null)
modelObject = false
isVisible = hasExclusions()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public User toUser() {
return user;
}

@NotNull
@Nullable
public Integer getId() {
return user.getId();
}
Expand All @@ -72,7 +72,7 @@ public void setId(Integer id) {
user.setId(id);
}

@NotNull
@Nullable
public String getUserName() {
return user.getUserName();
}
Expand All @@ -81,7 +81,7 @@ public void setUserName(final String value) {
user.setUserName(value);
}

@NotNull
@Nullable
public String getFirstName() {
return user.getFirstName();
}
Expand All @@ -90,7 +90,7 @@ public void setFirstName(final String value) {
user.setFirstName(value);
}

@NotNull
@Nullable
public String getLastName() {
return user.getLastName();
}
Expand All @@ -99,7 +99,7 @@ public void setLastName(final String value) {
user.setLastName(value);
}

@NotNull
@Nullable
public String getEmail() {
return user.getEmail();
}
Expand Down Expand Up @@ -142,12 +142,12 @@ public void removeRole(final Role role) {
user.removeRole(role);
}

@NotNull
@Nullable
public String getFullName() {
return user.getFullName();
}

@NotNull
@Nullable
public String getDisplayValue() {
return user.getDisplayValue();
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 8fcc8f0

Please sign in to comment.