Skip to content

Commit

Permalink
Allocate dataset dialog regression test.
Browse files Browse the repository at this point in the history
Signed-off-by: Uladzislau <[email protected]>
  • Loading branch information
Shyshkou_I authored and KUGDev committed Jan 31, 2025
1 parent 7e54ce7 commit 4ed6d0f
Show file tree
Hide file tree
Showing 27 changed files with 1,047 additions and 189 deletions.
24 changes: 12 additions & 12 deletions src/uiTest/kotlin/auxiliary/containers/AllocateDatasetDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ open class AllocateDatasetDialog(
* Fills in the parameters for allocating dataset.
*/
fun allocateDataset(
datasetName: String,
datasetOrganization: String,
allocationUnit: String,
primaryAllocation: Int,
secondaryAllocation: Int,
directory: Int,
recordFormat: String,
recordLength: Int,
blockSize: Int,
averageBlockLength: Int = 0
datasetName: String,
datasetOrganization: DatasetOrganization,
allocationUnit: String,
primaryAllocation: Int,
secondaryAllocation: Int,
directory: Int,
recordFormat: String,
recordLength: Int,
blockSize: Int,
averageBlockLength: Int = 0
) {
findAll<JTextFieldFixture>(datasetNameInputLoc)[0].text = datasetName
findAll<ComboBoxFixture>(datasetOrgDropDownLoc)[1].selectItem(datasetOrganization)
findAll<ComboBoxFixture>(datasetOrgDropDownLoc)[1].selectItem(datasetOrganization.value)

val datasetTextParams = findAll<JTextFieldFixture>(inputFieldLoc)
val datasetComboBoxParams = findAll<ComboBoxFixture>(dropdownsLoc)
Expand All @@ -63,7 +63,7 @@ open class AllocateDatasetDialog(
datasetTextParams[2].text = secondaryAllocation.toString()
datasetComboBoxParams[3].selectItem(recordFormat)

if (datasetOrganization == SEQUENTIAL_ORG_FULL) {
if (datasetOrganization == DatasetOrganization.PO_ORG_FULL_ITEM) {
datasetTextParams[3].text = recordLength.toString()
datasetTextParams[4].text = blockSize.toString()
datasetTextParams[5].text = averageBlockLength.toString()
Expand Down
5 changes: 2 additions & 3 deletions src/uiTest/kotlin/auxiliary/utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import okhttp3.tls.HeldCertificate
import org.junit.jupiter.api.TestInfo
import testutils.MockResponseDispatcher
import workingset.*
import workingset.*
//import workingset.testutils.InjectDispatcher
import java.awt.event.KeyEvent
import java.net.InetAddress
Expand Down Expand Up @@ -742,7 +741,7 @@ fun allocatePDSAndCreateMask(
actionMenu(remoteRobot, NEW_POINT_TEXT).click()
actionMenuItem(remoteRobot, DATASET_POINT_TEXT).click()
allocateDatasetDialog(fixtureStack) {
allocateDataset(datasetName, PO_ORG_FULL, "TRK", 10, 1, directory, "VB", 255, 6120)
allocateDataset(datasetName, DatasetOrganization.PO_ORG_FULL_ITEM, "TRK", 10, 1, directory, "VB", 255, 6120)
clickButton(OK_TEXT)
Thread.sleep(500)
}
Expand Down Expand Up @@ -855,7 +854,7 @@ fun allocateDataSet(
actionMenu(remoteRobot, "New").click()
actionMenuItem(remoteRobot, "Dataset").click()
allocateDatasetDialog(fixtureStack) {
allocateDataset(datasetName, POE_ORG_FULL, "TRK", 10, 1, 1, "VB", 255, 6120)
allocateDataset(datasetName, DatasetOrganization.POE_ORG_FULL_ITEM, "TRK", 10, 1, 1, "VB", 255, 6120)
clickButton(OK_TEXT)
Thread.sleep(3000)
}
Expand Down
2 changes: 1 addition & 1 deletion src/uiTest/kotlin/jes/CancelHoldReleaseJobTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class CancelHoldReleaseJobTest {
setUpTestEnvironment(fixtureStack, closableFixtureCollector, remoteRobot)
createValidConnectionWithMock(testInfo, connectionName, fixtureStack, closableFixtureCollector, remoteRobot)
injectTestInfoForPdsDataset(testInfo.displayName, datasetBody, datasetName)
mapListDatasets[datasetName] = listDS(datasetName, PDS_TYPE, PO_ORG_SHORT)
mapListDatasets[datasetName] = listDS(datasetName, "PDS", "PO")
injectListAllAllocatedDatasetsWithContents(testInfo,datasetName,mapListDatasets)
injectSingleMember(testInfo, datasetName, listMembersInDataset)
utilObject.createWsAndMask(wsName, connectionName, fixtureStack, closableFixtureCollector, remoteRobot,datasetMaskPair)
Expand Down
2 changes: 1 addition & 1 deletion src/uiTest/kotlin/jes/PurgeJobTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class PurgeJobTest {

injectTestInfoForPdsDataset(testInfo.displayName, datasetParams, datasetName)

mapListDatasets[datasetName] = listDS(datasetName, PDS_TYPE, PO_ORG_SHORT)
mapListDatasets[datasetName] = listDS(datasetName, "PDS", "PO")

injectListAllAllocatedDatasetsWithContents(testInfo, datasetName, mapListDatasets)
injectJobList(testInfo, datasetName, listMembersInDataset)
Expand Down
2 changes: 1 addition & 1 deletion src/uiTest/kotlin/jes/SubmitJobTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class SubmitJobTest {
)
injectTestInfoForPdsDataset(testInfo.displayName, datasetParams,datasetName)

mapListDatasets[datasetName] = listDS(datasetName, PDS_TYPE, PO_ORG_SHORT)
mapListDatasets[datasetName] = listDS(datasetName, "PDS", "PO")

injectListAllAllocatedDatasetsWithContents(testInfo,datasetName,mapListDatasets)
injectJobList(testInfo,datasetName,listMembersInDataset)
Expand Down
113 changes: 113 additions & 0 deletions src/uiTest/kotlin/tests/AddConnectionDialogTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
* Copyright (c) 2024 IBA Group.
*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBA Group
* Zowe Community
*/

package tests

import auxiliary.mockServer
import auxiliary.startMockServer
import io.kotest.core.annotation.Description

import com.intellij.driver.client.Driver
import org.junit.jupiter.api.*
import tests.utils.ActionMenuPoints
import tests.utils.FilesExplorerPanel
import tests.utils.dialogs.AddConnectionDialog
import tests.utils.notification.UnsecureConnectionDialog
import testutils.*

import workingset.testutils.injectTestInfo
import workingset.testutils.injectTestInfoRestTopology

@Description("Tests for interaction and filling the connection creation dialog")
class AddConnectionDialogTest {
private lateinit var ideDriver: Driver
private lateinit var filesExplorerPanel: FilesExplorerPanel
lateinit var addConnectionDialog: AddConnectionDialog
private lateinit var unsecureConnectionDialog: UnsecureConnectionDialog

companion object {
@JvmStatic
@BeforeAll
fun prepareBeforeAll() {
startMockServer()
IdeRunManager.prepareRunManager()
.runningIde
.resetTestEnv()
val ideDriver = IdeRunManager.getIdeDriver()
callRightSidePanel(ideDriver)
}

@JvmStatic
@AfterAll
fun afterAll() {
mockServer.shutdown()
}
}


@BeforeEach
fun prepareTestEnv() {
IdeRunManager.prepareRunManager()
.runningIde
.resetTestEnv()
ideDriver = IdeRunManager.getIdeDriver()
filesExplorerPanel = FilesExplorerPanel(ideDriver)
addConnectionDialog = AddConnectionDialog(ideDriver)
unsecureConnectionDialog = UnsecureConnectionDialog(ideDriver)
}

@AfterEach
fun finalizeTestEnv() {
IdeRunManager.prepareRunManager()
.runningIde
.resetTestEnv()
}

@Test
@Tag("New")
fun fieldsPresenceTest() {
filesExplorerPanel.openExplorerToolWindow(ActionMenuPoints.CONNECTION)



addConnectionDialog.passwordInput.click()
assert(addConnectionDialog.connectionDialogPanel.isVisible())
assert(addConnectionDialog.connectionNameLabel.isVisible())
assert(addConnectionDialog.connectionUrlLabel.isVisible())
assert(addConnectionDialog.connectionUsernameLabel.isVisible())
assert(addConnectionDialog.passwordLabel.isVisible())
assert(addConnectionDialog.passwordInput.isVisible())
assert(addConnectionDialog.questionMark.isVisible())
assert(addConnectionDialog.connectionDialogCancelButton.isVisible())
}

@Test
@Tag("New")
fun createInvalidConnectionTest(testInfo: TestInfo) {
injectTestInfo(testInfo)
injectTestInfoRestTopology(testInfo)

filesExplorerPanel.openExplorerToolWindow(ActionMenuPoints.CONNECTION)

addConnectionDialog.passwordInput.text = "passwordInput"
addConnectionDialog.connectionNameInput.text = "nameInput"
addConnectionDialog.urlInput.text = "https://${mockServer.hostName}:${mockServer.port}"
addConnectionDialog.userNameInput.text = "userNameInput"
addConnectionDialog.acceptSelfSignedCheckbox.click()
unsecureConnectionDialog.preceedButton.click()

addConnectionDialog.connectionDialogOkButton.click()
unsecureConnectionDialog.preceedButton.click()
}
}
161 changes: 161 additions & 0 deletions src/uiTest/kotlin/tests/AllocateDatasetTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
/*
* Copyright (c) 2024 IBA Group.
*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBA Group
* Zowe Community
*/

package tests

import auxiliary.ZOS_USERID
import auxiliary.mockServer
import auxiliary.responseDispatcher
import auxiliary.startMockServer
import io.kotest.core.annotation.Description
import testutils.*

import com.intellij.driver.client.Driver
import org.junit.jupiter.api.*
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.Arguments
import org.junit.jupiter.params.provider.MethodSource
import tests.utils.FilesExplorerPanel
import tests.utils.dialogs.AddConnectionDialog
import tests.utils.dialogs.AllocateDatasetDialog
import tests.utils.notification.AddWorkingSetSuccessNotification
import tests.utils.notification.UnsecureConnectionDialog

import workingset.*

import java.util.stream.Stream

@Description("Tests to check the functionality associated with dataset allocation")
class AllocateDatasetTest {
private lateinit var ideDriver: Driver
private lateinit var filesExplorerPanel: FilesExplorerPanel
lateinit var addConnectionDialog: AddConnectionDialog
private lateinit var unsecureConnectionDialog: UnsecureConnectionDialog
private lateinit var allocateDatasetDialog: AllocateDatasetDialog
private lateinit var addWsNotification: AddWorkingSetSuccessNotification

companion object {
const val connectionName = "valid connection"
const val wsName = "WS1"
private val allocMask = Pair("$ZOS_USERID.ALLOC.*", "z/OS")

@JvmStatic
fun provideOrgTypes(): Stream<Arguments> {
val datasetOrg = listOf(
DatasetOrganization.SEQUENTIAL_ORG_FULL_ITEM,
DatasetOrganization.PO_ORG_FULL_ITEM,
DatasetOrganization.POE_ORG_FULL_ITEM
)

return RecordFormatsShort.entries.flatMap { recordFormat ->
datasetOrg.map { organisationType ->
val datasetOrgShort = organisationType.value.substringAfter('(').substringBefore(')')
val allocateDatasetPram = AllocateDatasetParams(
name = datasetOrgShort,
preset = "Custom Dataset",
primaryAlloc = "10",
blockSize = "3200",
secondaryAlloc = "1",
avgBlockLen = "0",
unit = TRACKS_ALLOCATION_UNIT_SHORT,
dsOrganisationShort = datasetOrgShort
)
allocateDatasetPram.organisation = organisationType
allocateDatasetPram.format = recordFormat.name
if (organisationType != DatasetOrganization.SEQUENTIAL_ORG_FULL_ITEM) {
allocateDatasetPram.dirBlock = "1"
}
allocateDatasetPram.recordLength = if (recordFormat.name == F_RECORD_FORMAT_SHORT) "3200" else "80"

Arguments.of(allocateDatasetPram)
}
}.stream()
}

@JvmStatic
@BeforeAll
fun prepareBeforeAll(testInfo: TestInfo) {
startMockServer()

IdeRunManager.prepareRunManager()
.runningIde
.resetTestEnv()

val ideDriver = IdeRunManager.getIdeDriver()

callRightSidePanel(ideDriver)

createValidConnectionWithMock(
testInfo,
connectionName,
ideDriver
)
// Avoid check connection
Thread.sleep(3000)
createWsAndMask(ideDriver, wsName, connectionName, listOf(allocMask))


}

@JvmStatic
@AfterAll
fun afterAll() {
mockServer.shutdown()
}
}


@BeforeEach
fun prepareTestEnv() {
IdeRunManager.prepareRunManager()
.runningIde
.resetTestEnv()
ideDriver = IdeRunManager.getIdeDriver()
filesExplorerPanel = FilesExplorerPanel(ideDriver)
addConnectionDialog = AddConnectionDialog(ideDriver)
unsecureConnectionDialog = UnsecureConnectionDialog(ideDriver)
allocateDatasetDialog = AllocateDatasetDialog(ideDriver)
addWsNotification = AddWorkingSetSuccessNotification(ideDriver)
}

@AfterEach
fun finalizeTestEnv() {
IdeRunManager.prepareRunManager()
.runningIde
.resetTestEnv()
}

@Tag("New")
@ParameterizedTest
@MethodSource("provideOrgTypes")
fun allocateDatasetsTest(allocationParams: AllocateDatasetParams) {
filesExplorerPanel.callSubMenuForRow(0, NEW_POINT_TEXT, DATASET_POINT_TEXT)
allocateDatasetDialog.fillDialog(allocationParams)
responseDispatcher.injectAllocationResultPo(
allocationParams.organisation.toString(),
allocationParams.format.toString(),
allocationParams.name,
allocationParams.dsOrganisationShort.toString(),
allocationParams.recordLength.toString().toInt()
)
allocateDatasetDialog.okButton.click()

val isNotificationShown = addWsNotification.isAllocNotificationVisible(allocationParams.name)
addWsNotification.skipButton.click()

assert(isNotificationShown)

}

}
Loading

0 comments on commit 4ed6d0f

Please sign in to comment.