Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Mar 16 13:38

    thomasweingardt on master

    Update README.md (compare)

  • Feb 08 14:03

    thomasweingardt on master

    Update README.md (compare)

  • Feb 08 09:59

    thomasweingardt on master

    Update README.md (compare)

  • Feb 05 16:55

    thomasweingardt on master

    Update README for GitHub Packag… (compare)

  • Feb 05 05:10
    StefMa commented #208
  • Feb 04 11:41
    GrahamBorland opened #208
  • Jun 16 2020 02:56
    vRallev closed #51
  • Jun 16 2020 02:56
    vRallev closed #50
  • Mar 13 2020 13:16
    wietsebuseyne commented #206
  • Mar 13 2020 13:15
    wietsebuseyne commented #206
  • Jan 29 2020 00:42
    behi198 commented #205
  • Jan 28 2020 15:40

    lukaszkalnik on v1.0.1

    (compare)

  • Jan 28 2020 15:28

    lukaszkalnik on androidx_fragment_1_2_0_isinbackstack

    (compare)

  • Jan 28 2020 15:28

    lukaszkalnik on master

    bump version; remove version nu… Merge pull request #207 from gr… (compare)

  • Jan 28 2020 15:28
    lukaszkalnik closed #207
  • Jan 28 2020 15:12
    lukaszkalnik opened #207
  • Jan 28 2020 15:11

    lukaszkalnik on androidx_fragment_1_2_0_isinbackstack

    bump version; remove version nu… (compare)

  • Jan 28 2020 15:09

    jannisveerkamp on androidx_fragment_1_2_0_isinbackstack

    (compare)

  • Jan 28 2020 15:09

    jannisveerkamp on master

    workaround for AndroidX Fragmen… Merge pull request #205 from gr… (compare)

  • Jan 28 2020 15:09
    jannisveerkamp closed #205
Pascal Welsch
@passsy
Hello World!
Hello ThirtyInch users
Benedict
@BenedictP
nice 👍
Lmenegon
@Lmenegon

Hi! I'm actually testing my LoginViewPresenter, but when i run this test on my function loginClicked() it returns me a stack overflow error... Am I writing something in the wrong way? Could someone help me?

This is my test class:

`class LoginViewPresenterTests{
val getLoginInfoUseCaseMock = mockk<GetLoginInformationUseCase>()

val presenter = spyk(LoginViewPresenter(
        getLoginInfoUseCaseMock
))

private val mockView: LoginView = mockk<LoginView>()
private val emailMock = "email@test.com"
private val passwordMock = "password"
private val hostMock = "host"
private val paramsMock = mapOf<String, String>()


@Test
fun testLoginClicked() {
    val testPresenter = presenter.test()
    every { mockView.showLoginPopup(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.anyMap()) } just runs
    testPresenter.attachView(mockView)
    presenter.loginClicked(emailMock, passwordMock, hostMock, paramsMock)
    verify {mockView.showLoginPopup(hostMock, emailMock, passwordMock, paramsMock)}
}

}`

And this is my presenter code:
`class LoginViewPresenter @Inject constructor(private val getLoginInfoUseCase: GetLoginInformationUseCase)
: TiPresenter<LoginView>() {

private fun handleError(throwable: Throwable) {
    Timber.d(throwable, "Error while retrieving the login screen info")
}

override fun onAttachView(view: LoginView) {
    super.onAttachView(view)

    if (!view.isSliderSetup) {
        catch(this::handleError) {
            val info = runBlocking { getLoginInfoUseCase.get() }
            deliverToView { setSlideshow(info.portraitImages, info.landScapeImages) }
        }
    }
}

/**
 * Performs the login of the user.
 * @param host `String`: Host used to perform the login and other server related operations.
 * @param parameters `Map`: Optional addition parameters that are used during the login.
 */
fun loginClicked(defaultUsername: String, defaultPassword: String,
                 host: String, parameters: Map<String, String>?) {
    deliverToView { showLoginPopup(host, defaultUsername, defaultPassword, parameters) }
}

fun editHostClicked() {
    deliverToView { showEditHostPopup() }
}

fun saveHostClicked(value: String?) {
    if (value?.isNotBlank() == true) {

        var host = value

        if (!value.startsWith("https://")) {
            host = "https://$value"
        }

        if (!value.contains("-enterprise.zotsell.com")) {
            host = "$value-enterprise.zotsell.com"
        }

        deliverToView {
            saveHostInsideSettings(host)
            showSuccessPopup()
        }
    }
}

}`

Sorry for the bad formatting...
Pascal Welsch
@passsy
Looks fine from code. Haven't worked mit mockk yet. Seems the error is there
what's the stacktrace?
Lmenegon
@Lmenegon
I'm getting a stack overflow error... should i change the implementation of the mock?
Lmenegon
@Lmenegon
`java.lang.StackOverflowError
at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at io.mockk.proxy.jvm.advice.MethodCall.call(MethodCall.kt:14)
at io.mockk.proxy.jvm.advice.SelfCallEliminatorCallable.call(SelfCallEliminatorCallable.kt:14)
at io.mockk.impl.instantiation.JvmMockFactoryHelper.handleOriginalCall(JvmMockFactoryHelper.kt:81)
at io.mockk.impl.instantiation.JvmMockFactoryHelper.access$handleOriginalCall(JvmMockFactoryHelper.kt:18)
at io.mockk.impl.instantiation.JvmMockFactoryHelper$mockHandler$1$invocation$$inlined$stdFunctions$lambda$1.invoke(JvmMockFactoryHelper.kt:26)
at io.mockk.impl.stub.MockKStub$handleInvocation$originalPlusToString$1.invoke(MockKStub.kt:176)
at io.mockk.impl.stub.SpyKStub.defaultAnswer(SpyKStub.kt:14)
at io.mockk.impl.stub.MockKStub.answer(MockKStub.kt:46)
at io.mockk.impl.recording.states.AnsweringState.call(AnsweringState.kt:15)
at io.mockk.impl.recording.CommonCallRecorder.call(CommonCallRecorder.kt:48)
at io.mockk.impl.stub.MockKStub.handleInvocation(MockKStub.kt:223)
at io.mockk.impl.instantiation.JvmMockFactoryHelper$mockHandler$1.invocation(JvmMockFactoryHelper.kt:23)
at io.mockk.proxy.jvm.advice.Interceptor.call(Interceptor.kt:20)
at net.grandcentrix.thirtyinch.TiPresenter.onAttachView(TiPresenter.java:513)
at com.tradenetservices.zotsell.login.ui.fragment.presenter.LoginViewPresenter.onAttachView(LoginViewPresenter.kt:24)
at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at io.mockk.proxy.jvm.advice.MethodCall.call(MethodCall.kt:14)
at io.mockk.proxy.jvm.advice.SelfCallEliminatorCallable.call(SelfCallEliminatorCallable.kt:14)
at io.mockk.impl.instantiation.JvmMockFactoryHelper.handleOriginalCall(JvmMockFactoryHelper.kt:81)
at io.mockk.impl.instantiation.JvmMockFactoryHelper.access$handleOriginalCall(JvmMockFactoryHelper.kt:18)
at io.mockk.impl.instantiation.JvmMockFactoryHelper$mockHandler$1$invocation$$inlined$stdFunctions$lambda$1.invoke(JvmMockFactoryHelper.kt:26)
at io.mockk.impl.stub.MockKStub$handleInvocation$originalPlusToString$1.invoke(MockKStub.kt:176)
at io.mockk.impl.stub.SpyKStub.defaultAnswer(SpyKStub.kt:14)
at io.mockk.impl.stub.MockKStub.answer(MockKStub.kt:46)
at io.mockk.impl.recording.states.AnsweringState.call(AnsweringState.kt:15)
at io.mockk.impl.recording.CommonCallRecorder.call(CommonCallRecorder.kt:48)
at io.mockk.impl.stub.MockKStub.handleInvocation(MockKStub.kt:223)
at io.mockk.impl.instantiation.JvmMockFactoryHelper$mockHandler$1.invocation(JvmMockFactoryHelper.kt:23)
at io.mockk.proxy.jvm.advice.Interceptor.call(Interceptor.kt:20)
at com.tradenetservices.zotsell.login.ui.fragment.presenter.LoginViewPresenter.onAttachView(LoginViewPresenter.kt:32)
at com.tradenetservices.zotsell.login.ui.fragment.presenter.LoginViewPresenter.onAttachView(LoginViewPresenter.kt:16)
at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at io.mockk.proxy.jvm.advice.MethodCall.call(MethodCall.kt:14)
at io.mockk.proxy.jvm.advice.SelfCallEliminatorCallable.call(SelfCallEliminatorCallable.kt:14)
at io.mockk.impl.instantiation.JvmMockFactoryHelper.handleOriginalCall(JvmMockFactoryHelper.kt:81)
at io.mockk.impl.instantiation.JvmMockFactoryHelper.access$handleOriginalCall(JvmMockFactoryHelper.kt:18)
at io.mockk.impl.instantiation.JvmMockFactoryHelper$mockHandler$1$invocation$$inlined$stdFunctions$lambda$1.invoke(JvmMockFactoryHelper.kt:26)
at io.mockk.impl.stub.MockKStub$handleInvocation$originalPlusToString$1.invoke(MockKStub.kt:176)
at io.mockk.impl.stub.SpyKStub.defaultAnswer(SpyKStub.kt:14)
at io.mockk.impl.stub.MockKStub.answer(MockKStub.kt:46)
at io.mockk.impl.recording.st`
Pascal Welsch
@passsy
Could it be that accessing getLoginInfoUseCase.get() throws the StackOverflowError? Try to remove code until the StackOverflow is gone to see where it comes from