This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
Allow setting of gherkin terminal size using zos3270.gherkin.terminal.rows and zos3270.gherkin.terminal.columns, or in the gherkin scenario itself. #962
Merged
techcobweb
merged 2 commits into
main
from
mcobbett-1708-cps-controls-gherkin-terminal-size
Jul 26, 2024
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...270.manager/src/main/java/dev/galasa/zos3270/internal/gherkin/Gherkin3270Coordinator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
154 changes: 154 additions & 0 deletions
154
...nager/src/test/java/dev/galasa/zos3270/internal/gherkin/Gherkin3270GivenTerminalTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
/* | ||
* Copyright contributors to the Galasa project | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package dev.galasa.zos3270.internal.gherkin; | ||
|
||
import java.util.Map; | ||
|
||
import org.junit.Test; | ||
|
||
import dev.galasa.framework.spi.language.gherkin.GherkinTest; | ||
import dev.galasa.zos3270.Zos3270ManagerException; | ||
import dev.galasa.zos3270.common.screens.TerminalSize; | ||
import dev.galasa.zos3270.internal.Zos3270ManagerImpl; | ||
|
||
import static org.assertj.core.api.Assertions.*; | ||
|
||
public class Gherkin3270GivenTerminalTest { | ||
|
||
|
||
public class MockZos3270Manager extends Zos3270ManagerImpl { | ||
private Map<String,String> cpsProperties; | ||
|
||
public MockZos3270Manager(Map<String,String> cpsProperties) { | ||
this.cpsProperties = cpsProperties; | ||
} | ||
|
||
public String getCpsProperty(String fullPropertyName) throws Zos3270ManagerException { | ||
return cpsProperties.get(fullPropertyName); | ||
} | ||
} | ||
|
||
public class MockGherkinCoordinator extends Gherkin3270Coordinator { | ||
public MockGherkinCoordinator(Zos3270ManagerImpl manager, GherkinTest gherkinTest) { | ||
super(manager, gherkinTest); | ||
} | ||
} | ||
|
||
@Test | ||
public void testGherkin3270GivenTerminalCanBeCreatedOk() { | ||
|
||
Map<String,String> cpsProps = Map.of(); | ||
MockZos3270Manager mockManager = new MockZos3270Manager(cpsProps); | ||
MockGherkinCoordinator mockCoordinator = new MockGherkinCoordinator(mockManager, null); | ||
|
||
new Gherkin3270GivenTerminal(mockCoordinator, mockManager); | ||
} | ||
|
||
@Test | ||
public void testGherkin3270CanGetDefaultPreferredTerminalSizeEmptyCPS() throws Exception { | ||
Map<String,String> cpsProps = Map.of( | ||
// "zos3270.gherkin.terminal.rows","24", | ||
// "zos3270.gherkin.terminal.columns","80" | ||
); | ||
MockZos3270Manager mockManager = new MockZos3270Manager(cpsProps); | ||
MockGherkinCoordinator mockCoordinator = new MockGherkinCoordinator(mockManager, null); | ||
|
||
Gherkin3270GivenTerminal terminal = new Gherkin3270GivenTerminal(mockCoordinator, mockManager); | ||
TerminalSize preferredTerminalSize = terminal.getPreferredTerminalSize("",""); | ||
|
||
assertThat(preferredTerminalSize.getRows()).isEqualTo(Gherkin3270GivenTerminal.DEFAULT_TERMINAL_ROWS); | ||
assertThat(preferredTerminalSize.getColumns()).isEqualTo(Gherkin3270GivenTerminal.DEFAULT_TERMINAL_COLUMNS); | ||
} | ||
|
||
@Test | ||
public void testGherkin3270CanGetDefaultPreferredTerminalSizeFromCPS() throws Exception { | ||
Map<String,String> cpsProps = Map.of( | ||
"zos3270.gherkin.terminal.rows","25", | ||
"zos3270.gherkin.terminal.columns","81" | ||
); | ||
MockZos3270Manager mockManager = new MockZos3270Manager(cpsProps); | ||
MockGherkinCoordinator mockCoordinator = new MockGherkinCoordinator(mockManager, null); | ||
|
||
Gherkin3270GivenTerminal terminal = new Gherkin3270GivenTerminal(mockCoordinator, mockManager); | ||
TerminalSize preferredTerminalSize = terminal.getPreferredTerminalSize("",""); | ||
|
||
assertThat(preferredTerminalSize.getRows()).isEqualTo(25); | ||
assertThat(preferredTerminalSize.getColumns()).isEqualTo(81); | ||
} | ||
|
||
@Test | ||
public void testGherkin3270CanGetDefaultPreferredTerminalSizeFromGherkinStatement() throws Exception { | ||
Map<String,String> cpsProps = Map.of( | ||
"zos3270.gherkin.terminal.rows","25", | ||
"zos3270.gherkin.terminal.columns","81" | ||
); | ||
MockZos3270Manager mockManager = new MockZos3270Manager(cpsProps); | ||
MockGherkinCoordinator mockCoordinator = new MockGherkinCoordinator(mockManager, null); | ||
|
||
Gherkin3270GivenTerminal terminal = new Gherkin3270GivenTerminal(mockCoordinator, mockManager); | ||
TerminalSize preferredTerminalSize = terminal.getPreferredTerminalSize("48","64"); | ||
|
||
assertThat(preferredTerminalSize.getRows()).isEqualTo(48); | ||
assertThat(preferredTerminalSize.getColumns()).isEqualTo(64); | ||
} | ||
|
||
@Test | ||
public void testGherkin3270GetDefaultPreferredTerminalSizeFailsIfCPSRowsPropNotANumber() throws Exception { | ||
Map<String,String> cpsProps = Map.of( | ||
"zos3270.gherkin.terminal.rows","hello" | ||
// "zos3270.gherkin.terminal.columns","81" | ||
); | ||
MockZos3270Manager mockManager = new MockZos3270Manager(cpsProps); | ||
MockGherkinCoordinator mockCoordinator = new MockGherkinCoordinator(mockManager, null); | ||
|
||
Gherkin3270GivenTerminal terminal = new Gherkin3270GivenTerminal(mockCoordinator, mockManager); | ||
|
||
// When... | ||
Zos3270ManagerException ex = catchThrowableOfType( | ||
() -> terminal.getPreferredTerminalSize("",""), | ||
Zos3270ManagerException.class ); | ||
|
||
assertThat(ex).hasMessageContaining("does not contain a number"); | ||
} | ||
|
||
@Test | ||
public void testGherkin3270GetDefaultPreferredTerminalSizeFailsIfGherkinStatementValueNotANumber() throws Exception { | ||
Map<String,String> cpsProps = Map.of( | ||
"zos3270.gherkin.terminal.rows","25", | ||
"zos3270.gherkin.terminal.columns","81" | ||
); | ||
MockZos3270Manager mockManager = new MockZos3270Manager(cpsProps); | ||
MockGherkinCoordinator mockCoordinator = new MockGherkinCoordinator(mockManager, null); | ||
|
||
Gherkin3270GivenTerminal terminal = new Gherkin3270GivenTerminal(mockCoordinator, mockManager); | ||
|
||
// When... | ||
Zos3270ManagerException ex = catchThrowableOfType( | ||
() -> terminal.getPreferredTerminalSize("hello-notanumber","notanumber"), | ||
Zos3270ManagerException.class ); | ||
|
||
assertThat(ex).hasMessageContaining("does not contain a number"); | ||
} | ||
|
||
@Test | ||
public void testGherkin3270GetDefaultPreferredTerminalSizeFailsIfCPSColumnsPropNotANumber() throws Exception { | ||
Map<String,String> cpsProps = Map.of( | ||
"zos3270.gherkin.terminal.rows","24", | ||
"zos3270.gherkin.terminal.columns","hello" | ||
); | ||
MockZos3270Manager mockManager = new MockZos3270Manager(cpsProps); | ||
MockGherkinCoordinator mockCoordinator = new MockGherkinCoordinator(mockManager, null); | ||
|
||
Gherkin3270GivenTerminal terminal = new Gherkin3270GivenTerminal(mockCoordinator, mockManager); | ||
|
||
// When... | ||
Zos3270ManagerException ex = catchThrowableOfType( | ||
() -> terminal.getPreferredTerminalSize("",""), | ||
Zos3270ManagerException.class ); | ||
|
||
assertThat(ex).hasMessageContaining("does not contain a number"); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rows and columns might need swapping for this log message - for example with 24 rows and 80 columns, this would read as
24 x 80
instead of80 x 24
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do wonder whether mainframers use 24x80
This is from host on demand:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adam Coulthard