Search in sources :

Example 16 with ConsoleResult

use of com.thoughtworks.go.util.command.ConsoleResult in project gocd by gocd.

the class P4CommandTestBase method shouldCheckConnection.

@Test
void shouldCheckConnection() {
    ConsoleResult info = p4.checkConnection();
    // unable to verify failure for wrong password
    assertThat(info.returnValue()).isEqualTo(0);
    assertThat(info.error().size()).isEqualTo(0);
}
Also used : ConsoleResult(com.thoughtworks.go.util.command.ConsoleResult) Test(org.junit.jupiter.api.Test)

Example 17 with ConsoleResult

use of com.thoughtworks.go.util.command.ConsoleResult in project gocd by gocd.

the class P4OutputParserTest method shouldIgnoreEmptyLinesInChanges.

@Test
void shouldIgnoreEmptyLinesInChanges() {
    final String output = "Change 539921 on 2008/09/24 by abc@SomeRefinery_abc_sa1-sgr-xyz-001 'more work in progress on ABC un'\n" + "Change 539920 on 2008/09/24 by " + "abc@SomeRefinery_abc_sa1-sgr-xyz-001 'Fixed pipeline for abc-new-sale'\n" + "Change 539919 on 2008/09/24 by " + "james@SomeRefinery_def_sa1-sgr-xyz-001 'Assignment stage to send ok and'\n" + "Change 539918 on 2008/09/24 by abc@SomeRefinery_abc_sa1-sgr-xyz-001 'More refactoring and code clean'\n" + "Change 539917 on 2008/09/24 by thomas@tom_ws_stuff 'added client name for Arza SW'\n" + "Change 539916 on 2008/09/24 by alex@SA2-COUNT-LAX-001 'sending the context further '\n" + "Change 539915 on 2008/09/24 by ellen@ellen-box-1 'TT 678 cause:Old code try to'\n" + "Change 539914 on 2008/09/24 by valerie@ExcelSheets_New 'update sheet comments '\n" + "\n" + "Change 539913 on 2008/09/24 by perforce@SOM-NAME-HERE-HOST-1 'apply new version numbers via A'\n" + "Change 539912 on 2008/09/24 by lance@lance-box-1 'Corrected a typo. '\n" + "\n" + "Change 539911 on 2008/09/24 by lance@lance-box-1 'corrected a typo. '\n" + "Change 539910 on 2008/09/24 by josh@josh_box_1 'Changes to remove hacks I had m'\n" + "Change 539909 on 2008/09/24 by thomas@tom_ws_stuff 'Added Arza SW to add request '\n" + "Change 539908 on 2008/09/24 by padma@Padma '1. Fix #2644 : When the FSOi'\n" + "Change 539907 on 2008/09/24 by berlin@Dans_Box 'Added GetDocumentMetadataForEdi'\n" + "Change 539906 on 2008/09/24 by lance@lance-box-1 'Added detail aboutPFP. '\n" + "Change 539904 on 2008/09/24 by lance@lance-box-1 'Added a detail about PFP. '\n" + "Change 539903 on 2008/09/24 by nitya@docs_box 'Updated for lam, am 20080923'\n" + "Change 539902 on 2008/09/24 by abc@SomeRefinery_abc_sa1-sgr-xyz-001 'Work in progress '\n" + "Change 539901 on 2008/09/24 by anil@anil-box-1 'Added all columns of AA_TASK to'\n" + "";
    when(p4Client.describe(any(Long.class))).thenReturn("Change 539921 by abc@SomeRefinery_abc_sa1-sgr-xyz-001 on 2008/09/24 12:10:00\n" + "\n" + "\tmore work in progress on ABC unit test\n" + "\n" + "Affected files ...\n" + "");
    List<Modification> modifications = parser.modifications(new ConsoleResult(0, Arrays.asList(output.split("\n")), new ArrayList<>(), new ArrayList<>(), new ArrayList<>()));
    assertThat(modifications.size()).isEqualTo(20);
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) ConsoleResult(com.thoughtworks.go.util.command.ConsoleResult) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Example 18 with ConsoleResult

use of com.thoughtworks.go.util.command.ConsoleResult in project gocd by gocd.

the class P4OutputParserTest method shouldIgnoreBadLinesAndLogThem.

@Test
void shouldIgnoreBadLinesAndLogThem() {
    try (LogFixture logging = logFixtureFor(P4OutputParser.class, Level.DEBUG)) {
        final String output = "Change 539921 on 2008/09/24 " + "by abc@SomeRefinery_abc_sa1-sgr-xyz-001 'more work in progress on MDC un'\n";
        final String description = "Change that I cannot parse :-(\n";
        when(p4Client.describe(any(Long.class))).thenReturn(description);
        List<Modification> modifications = parser.modifications(new ConsoleResult(0, Arrays.asList(output.split("\n")), new ArrayList<>(), new ArrayList<>(), new ArrayList<>()));
        assertThat(modifications.size()).isEqualTo(0);
        assertThat(logging.getLog()).contains(description);
    }
}
Also used : LogFixture(com.thoughtworks.go.util.LogFixture) Modification(com.thoughtworks.go.domain.materials.Modification) ConsoleResult(com.thoughtworks.go.util.command.ConsoleResult) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Example 19 with ConsoleResult

use of com.thoughtworks.go.util.command.ConsoleResult in project gocd by gocd.

the class P4OutputParserTest method shouldThrowExceptionIfP4ReturnDifferentDateFormatWhenCannotParseFistLineOfP4Describe.

@Test
void shouldThrowExceptionIfP4ReturnDifferentDateFormatWhenCannotParseFistLineOfP4Describe() {
    String output = "Change 2 on 08/08/19 by cceuser@connect4 'some modification message'";
    Modification modification = new Modification();
    try {
        parser.parseFistline(modification, output, new ConsoleResult(0, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>()));
    } catch (P4OutputParseException e) {
        assertThat(e.getMessage()).contains("Could not parse P4 describe:");
    }
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) ConsoleResult(com.thoughtworks.go.util.command.ConsoleResult) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Example 20 with ConsoleResult

use of com.thoughtworks.go.util.command.ConsoleResult in project gocd by gocd.

the class P4OutputParserTest method shouldParseDescriptionProperly_Bug2456.

@Test
void shouldParseDescriptionProperly_Bug2456() throws P4OutputParseException {
    String description = "Change 570548 by michael@michael_AB2-ENV-WXP-000_ABcore on 2009/01/12 14:47:04\n" + "\n" + "\tAdd a WCF CrossDomainPolicyService and CrossDomain.xml.\n" + "\tUpdate service reference.\n" + "\tUpdate app.config and template config files.\n" + "\n" + "Affected files ...\n" + "\n" + "... //APP/AB/Core/Somemv.Core/Somemv.Core.Security.ServiceContracts/ICrossDomainPolicyService.cs#1 add\n" + "... //APP/AB/Core/Somemv.Core/Somemv.Core.Security.ServiceContracts/Somemv.Core.Security.ServiceContracts.csproj#3" + " edit\n" + "... //APP/AB/Core/Somemv.Core/Somemv.Core.Security.Services/CrossDomainPolicyService.cs#1 add\n" + "... //APP/AB/Core/Somemv.Core/Somemv.Core.Security.Services/Somemv.Core.Security.Services.csproj#4 edit\n" + "... //APP/AB/Core/Somemv.Core/Somemv.Core.ServiceReferences/Somemv.Core.ServiceReferences.csproj#44 edit\n" + "... //APP/AB/Core/Somemv.Core/Somemv.Core.ServiceReferences/Service References/SecurityService/" + "SecurityService33.xsd#2 edit\n" + "... //APP/AB/Core/Somemv.Core/Somemv.Core.ServiceReferences/app.config#30 edit\n" + "... //APP/AB/Core/Somemv.Simulation/Somemv.Simulation.Coordinator.Services/Analysis/AnalysisServiceAdapter.cs#30" + " edit\n" + "... //APP/AB/Core/Somemv.Simulation/Somemv.Simulation.Services/ManageableService.cs#4 edit\n" + "... //APP/AB/Core/Products/Somemv.RemotingService/App.config#102 edit\n" + "... //APP/AB/Core/Products/Somemv.RemotingService/CrossDomain.xml#1 add\n" + "... //APP/AB/Core/Products/Somemv.RemotingService/Somemv.RemotingService.csproj#53 edit\n" + "... //APP/AB/Core/Templates/Somemv.RemotingService/app_template.config#69 edit\n" + "... //APP/AB/Core/Templates/Somemv.RemotingService/coordinator_template.config#69 edit\n" + "";
    Modification modification = parser.modificationFromDescription(description, new ConsoleResult(0, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>()));
    assertThat(modification.getComment()).isEqualTo("Add a WCF CrossDomainPolicyService and CrossDomain.xml.\n" + "Update service reference.\n" + "Update app.config and template config files.");
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) ConsoleResult(com.thoughtworks.go.util.command.ConsoleResult) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Aggregations

ConsoleResult (com.thoughtworks.go.util.command.ConsoleResult)24 Test (org.junit.jupiter.api.Test)12 Modification (com.thoughtworks.go.domain.materials.Modification)11 ArrayList (java.util.ArrayList)10 CommandLine (com.thoughtworks.go.util.command.CommandLine)5 Test (org.junit.Test)5 ClassPathResource (org.springframework.core.io.ClassPathResource)4 Matchers.containsString (org.hamcrest.Matchers.containsString)3 ModifiedFile (com.thoughtworks.go.domain.materials.ModifiedFile)1 LogFixture (com.thoughtworks.go.util.LogFixture)1 CommandLineException (com.thoughtworks.go.util.command.CommandLineException)1 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)1 InMemoryStreamConsumer (com.thoughtworks.go.util.command.InMemoryStreamConsumer)1 StringWriter (java.io.StringWriter)1 DateTime (org.joda.time.DateTime)1