use of org.beryx.textio.TextIO in project mars-sim by mars-sim.
the class CommanderInfo method main.
public static void main(String[] args) {
TextIO textIO = TextIoFactory.getTextIO();
new CommanderInfo().accept(textIO, null);
}
use of org.beryx.textio.TextIO in project mars-sim by mars-sim.
the class ConsoleApp method main.
public static void main(String... args) {
UserChannel channel = null;
if ((args.length > 1) && args[1].equals("--swing")) {
TextIO term = TextIoFactory.getTextIO();
channel = new TextIOChannel(term);
} else {
channel = new StreamChannel(System.in, System.out);
}
Set<ConversationRole> roles = new HashSet<>();
roles.add(ConversationRole.ADMIN);
Conversation conversation = new Conversation(channel, new TopLevel(), roles, null);
conversation.interact();
}
use of org.beryx.textio.TextIO in project aws-codeguru-cli by aws.
the class ArtifactAdapterTest method test_zipAndUpload_happyCaseGitFilesOnly.
@Test
public void test_zipAndUpload_happyCaseGitFilesOnly() throws Exception {
val repoDir = Paths.get("./test-data/two-commits").toRealPath();
val tempDir = Files.createTempDirectory("test_zipAndUpload_happyCaseGitFilesOnly");
val bucketName = "some-bucket";
// only include files from the util dir.
final List<Path> buildDirs = Collections.emptyList();
val mockTerminal = new MockTextTerminal();
// answer No to the question if only files under version control should be scanned.
mockTerminal.getInputs().add("y");
val config = Configuration.builder().s3Client(s3client).interactiveMode(true).textIO(new TextIO(mockTerminal)).versionedFiles(Arrays.asList(repoDir.resolve("test.txt"))).build();
Answer<Object> answer = invocationOnMock -> {
Path filePath = invocationOnMock.getArgument(1);
Assertions.assertTrue(filePath.toFile().isFile());
try (val zipFile = new ZipFile(filePath.toFile())) {
val entries = zipFile.entries();
int count = 0;
while (entries.hasMoreElements()) {
val s = entries.nextElement().getName();
val original = repoDir.resolve(s).toFile();
Assertions.assertTrue(original.isFile(), "Not a valid file: " + original);
Assertions.assertFalse(s.startsWith(".."));
if (!s.startsWith("git/")) {
// count the files that are not in the git folder.
count++;
}
}
Assertions.assertEquals(1, count, "Unexpected number of files in zip.");
}
return null;
};
doAnswer(answer).when(s3client).putObject(any(PutObjectRequest.class), any(Path.class));
val metaData = ArtifactAdapter.zipAndUpload(config, tempDir, repoDir, Arrays.asList(repoDir), buildDirs, bucketName);
Assertions.assertNull(metaData.getBuildKey());
Assertions.assertNotNull(metaData.getSourceKey());
}
use of org.beryx.textio.TextIO in project aws-codeguru-cli by aws.
the class AssociationAdapterTest method test_getAssociatedGuruRepo_createNewWithCreateBucketInteractive.
@Test
public void test_getAssociatedGuruRepo_createNewWithCreateBucketInteractive() {
val bucketName = "some-bucket";
val fakeArn = "123";
val expected = RepositoryAssociation.builder().associationArn(fakeArn).state(RepositoryAssociationState.ASSOCIATED).build();
val emptyListResponse = ListRepositoryAssociationsResponse.builder().repositoryAssociationSummaries(Collections.emptyList()).build();
when(guruFrontendService.listRepositoryAssociations(any(ListRepositoryAssociationsRequest.class))).thenReturn(emptyListResponse);
when(s3client.headBucket(any(HeadBucketRequest.class))).thenThrow(NoSuchBucketException.class);
when(guruFrontendService.associateRepository(any(AssociateRepositoryRequest.class))).thenReturn(AssociateRepositoryResponse.builder().repositoryAssociation(expected).build());
when(guruFrontendService.describeRepositoryAssociation(any(DescribeRepositoryAssociationRequest.class))).thenReturn(DescribeRepositoryAssociationResponse.builder().repositoryAssociation(expected).build());
val mockTerminal = new MockTextTerminal();
mockTerminal.getInputs().add("y");
val config = Configuration.builder().guruFrontendService(guruFrontendService).interactiveMode(true).s3Client(s3client).repoName("some-repo-name").textIO(new TextIO(mockTerminal)).build();
val association = AssociationAdapter.getAssociatedGuruRepo(config);
Assertions.assertEquals(expected.associationArn(), association.associationArn());
}
use of org.beryx.textio.TextIO in project aws-codeguru-cli by aws.
the class AssociationAdapterTest method test_getAssociatedGuruRepo_createNewWithCreateBucketInteractiveAbort.
@Test
public void test_getAssociatedGuruRepo_createNewWithCreateBucketInteractiveAbort() {
val bucketName = "some-bucket";
val emptyListResponse = ListRepositoryAssociationsResponse.builder().repositoryAssociationSummaries(Collections.emptyList()).build();
when(guruFrontendService.listRepositoryAssociations(any(ListRepositoryAssociationsRequest.class))).thenReturn(emptyListResponse);
when(s3client.headBucket(any(HeadBucketRequest.class))).thenThrow(NoSuchBucketException.class);
val mockTerminal = new MockTextTerminal();
mockTerminal.getInputs().add("n");
val config = Configuration.builder().guruFrontendService(guruFrontendService).interactiveMode(true).s3Client(s3client).repoName("some-repo-name").textIO(new TextIO(mockTerminal)).build();
GuruCliException ret = Assertions.assertThrows(GuruCliException.class, () -> AssociationAdapter.getAssociatedGuruRepo(config));
Assertions.assertEquals(ErrorCodes.USER_ABORT, ret.getErrorCode());
}
Aggregations