<commit_before>package pl.droidsonroids.droidsmap

import com.nhaarman.mockito_kotlin.mock
import com.nhaarman.mockito_kotlin.never
import com.nhaarman.mockito_kotlin.verify
import org.junit.Before
import org.junit.Test
import pl.droidsonroids.droidsmap.feature.office.ui.OfficeUiGateway
import pl.droidsonroids.droidsmap.feature.room.ui.RoomUiGateway

class FlowManagerTest {

    lateinit var roomGatewayMock: RoomUiGateway
    lateinit var officeGatewayMock: OfficeUiGateway
    lateinit var terminateListener: Terminatable
    lateinit var flowManager: FlowManager

    @Before
    fun setUp() {
        roomGatewayMock = mock()
        officeGatewayMock = mock()
        terminateListener = mock()
        flowManager = FlowManager(officeGatewayMock, roomGatewayMock, terminateListener)
    }

    @Test
    fun `view features get notified about incoming room perspective change`() {

        flowManager.currentPerspective = Perspective.OFFICE
        flowManager.onBackButtonPressed()

        verify(officeGatewayMock).onPerspectiveChanged(false)

        verify(roomGatewayMock, never()).onPerspectiveChanged(false)
        verify(roomGatewayMock, never()).onPerspectiveChanged(true)
        verify(officeGatewayMock, never()).onPerspectiveChanged(true)
    }

    @Test
    fun `view features get notified about incoming office perspective change`() {

        flowManager.currentPerspective = Perspective.ROOM
        flowManager.onBackButtonPressed()

        verify(roomGatewayMock).onPerspectiveChanged(false)
        verify(officeGatewayMock).onPerspectiveChanged(true)

        verify(roomGatewayMock, never()).onPerspectiveChanged(true)
        verify(officeGatewayMock, never()).onPerspectiveChanged(false)
    }
}<commit_msg>Test app gets terminated upon back button press in office perspective<commit_after>package pl.droidsonroids.droidsmap

import com.nhaarman.mockito_kotlin.mock
import com.nhaarman.mockito_kotlin.never
import com.nhaarman.mockito_kotlin.verify
import org.junit.Before
import org.junit.Test
import pl.droidsonroids.droidsmap.feature.office.ui.OfficeUiGateway
import pl.droidsonroids.droidsmap.feature.room.ui.RoomUiGateway

class FlowManagerTest {

    lateinit var roomGatewayMock: RoomUiGateway
    lateinit var officeGatewayMock: OfficeUiGateway
    lateinit var terminateListener: Terminatable
    lateinit var flowManager: FlowManager

    @Before
    fun setUp() {
        roomGatewayMock = mock()
        officeGatewayMock = mock()
        terminateListener = mock()
        flowManager = FlowManager(officeGatewayMock, roomGatewayMock, terminateListener)
    }

    @Test
    fun `view features get notified about incoming room perspective change`() {

        flowManager.currentPerspective = Perspective.OFFICE
        flowManager.onBackButtonPressed()

        verify(officeGatewayMock).onPerspectiveChanged(false)

        verify(roomGatewayMock, never()).onPerspectiveChanged(false)
        verify(roomGatewayMock, never()).onPerspectiveChanged(true)
        verify(officeGatewayMock, never()).onPerspectiveChanged(true)
    }

    @Test
    fun `view features get notified about incoming office perspective change`() {

        flowManager.currentPerspective = Perspective.ROOM
        flowManager.onBackButtonPressed()

        verify(roomGatewayMock).onPerspectiveChanged(false)
        verify(officeGatewayMock).onPerspectiveChanged(true)

        verify(roomGatewayMock, never()).onPerspectiveChanged(true)
        verify(officeGatewayMock, never()).onPerspectiveChanged(false)
    }

    @Test
    fun `application gets terminated upon back button press if in office perspective`() {
        flowManager.currentPerspective = Perspective.OFFICE
        flowManager.onBackButtonPressed()

        verify(terminateListener).onTerminate()
    }
}
{'fraction_non_alphanumeric': 0.07627564439768543, 'fraction_numerical': 0.0, 'mean_word_length': 4.13225371120108, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1371642', 'n_tokens_mistral': 1057, 'n_tokens_neox': 1033, 'n_words': 203}