Package com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data

Examples of com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.GerritProject


        GerritTrigger trigger = GerritTrigger.getTrigger(freestyleJob);
        assertNotNull(trigger);
        List<GerritProject> gerritProjects = trigger.getGerritProjects();
        assertNotNull(gerritProjects);
        assertThat(gerritProjects.size(), equalTo(1));
        GerritProject gerritProject = gerritProjects.get(0);
        assertThat(gerritProject.getPattern(), equalTo("project"));
        List<Branch> branches = gerritProject.getBranches();
        assertThat(branches.size(), equalTo(1));
        Branch branch = branches.get(0);
        assertThat(branch.getPattern(), equalTo("bra.*"));
        List<PluginGerritEvent> triggerOnEvents = trigger.getTriggerOnEvents();
        assertThat(triggerOnEvents.size(), equalTo(2));
View Full Code Here


        GerritTrigger trigger = GerritTrigger.getTrigger(matrixJob);
        assertNotNull(trigger);
        List<GerritProject> gerritProjects = trigger.getGerritProjects();
        assertNotNull(gerritProjects);
        assertThat(gerritProjects.size(), equalTo(1));
        GerritProject gerritProject = gerritProjects.get(0);
        assertThat(gerritProject.getPattern(), equalTo("project"));
        List<Branch> branches = gerritProject.getBranches();
        assertThat(branches.size(), equalTo(1));
        Branch branch = branches.get(0);
        assertThat(branch.getPattern(), equalTo(".*er"));
        List<PluginGerritEvent> triggerOnEvents = trigger.getTriggerOnEvents();
        assertThat(triggerOnEvents.size(), equalTo(2));
View Full Code Here

     */
    private GerritProject createGerritProject(String pattern, CompareType compareType) {
        List<Branch> branches = new LinkedList<Branch>();
        Branch branch = new Branch(compareType, "master");
        branches.add(branch);
        GerritProject config = new GerritProject(CompareType.PLAIN, pattern, branches, null, null, null);
        return config;
    }
View Full Code Here

     * Set up the projects and triggers needed by tests.
     * @throws Exception if so
     */
    @Before
    public void createProjectsAndTriggers() throws Exception {
        GerritProject gP1 = createGerritProject("test/project1", CompareType.PLAIN);
        GerritProject gP2 = createGerritProject("test/project2", CompareType.PLAIN);
        GerritProject gP3 = createGerritProject("test/project3", CompareType.PLAIN);
        GerritProject gP4 = createGerritProject("test/project4", CompareType.PLAIN);
        GerritProject gP5 = createGerritProject("test/project5", CompareType.PLAIN);

        GerritTrigger trigger1 = createGerritTrigger(Arrays.asList(gP1, gP2, gP1), true, false);
        GerritTrigger trigger2 = createGerritTrigger(Arrays.asList(gP2, gP1, gP5), true, false);
        GerritTrigger trigger3 = createGerritTrigger(Arrays.asList(gP1, gP3, gP2, gP5), true, false);

View Full Code Here

     */
    public static FreeStyleProject createGerritTriggeredJob(JenkinsRule rule,
            String projectName, String serverName) throws Exception {
        FreeStyleProject p = rule.createFreeStyleProject(projectName);
        List<GerritProject> projects = new LinkedList<GerritProject>();
        projects.add(new GerritProject(CompareType.ANT, "**",
                Collections.singletonList(new Branch(CompareType.ANT, "**")), null, null, null));
        p.addTrigger(new GerritTrigger(projects, null,
                null, null, null, null, null, null, null, null, null, null,
                false, false, true, false, false, null, null, null, null, null, null, null,
                null, serverName, null, null, false, false, null, null));
View Full Code Here

    public static FreeStyleProject createGerritTriggeredJobForCommentAdded(JenkinsRule rule,
            String name, String serverName)
            throws Exception {
        FreeStyleProject p = rule.createFreeStyleProject(name);
        List<GerritProject> projects = new LinkedList<GerritProject>();
        projects.add(new GerritProject(CompareType.ANT, "**",
                Collections.singletonList(new Branch(CompareType.ANT, "**")), null, null, null));
        PluginCommentAddedEvent event = new PluginCommentAddedEvent("CRVW", "1");
        List<PluginGerritEvent> list = new LinkedList<PluginGerritEvent>();
        list.add(event);
        p.addTrigger(new GerritTrigger(projects, null,
View Full Code Here

      List<GerritProject> dynamicGerritProjects = new ArrayList<GerritProject>();
      List<Branch> branches = null;
      List<Topic> topics = null;
      List<FilePath> filePaths = null;
      List<FilePath> forbiddenFilePaths = null;
      GerritProject dynamicGerritProject = null;

      String line = "";
      int lineNr = 0;
      while ((line = reader.readLine()) != null) {
        ++lineNr;
        // Remove any comments starting with a #
        int commentPos = line.indexOf('#');
        if (commentPos > -1) {
          line = line.substring(0, commentPos);
        }

        // Remove any comments starting with a ;
        commentPos = line.indexOf(';');
        if (commentPos > -1) {
          line = line.substring(0, commentPos);
        }

        // Trim leading and trailing whitespace
        line = line.trim();
        if (line.isEmpty()) {
          continue;
        }

        Matcher matcher = linePattern.matcher(line);
        if (!matcher.matches()) {
          throw new ParseException("Line " + lineNr + ": cannot parse '" + line + "'", lineNr);
        }

        // CS IGNORE MagicNumber FOR NEXT 3 LINES. REASON: ConstantsNotNeeded
        String item = matcher.group(1);
        String oper = matcher.group(2);
        String text = matcher.group(3);
        if (item == null || oper == null || text == null) {
          throw new ParseException("Line " + lineNr + ": cannot parse '" + line + "'", lineNr);
        }
        char operChar = oper.charAt(0);
        CompareType type = CompareType.findByOperator(operChar);

        logger.trace("==> item:({0}) oper:({1}) text:({2})", new Object[]{item, oper, text});

        if (SHORTNAME_PROJECT.equals(item)) { // Project
          // stash previous project to the list
          if (dynamicGerritProject != null) {
            dynamicGerritProjects.add(dynamicGerritProject);
          }

          branches = new ArrayList<Branch>();
          topics = new ArrayList<Topic>();
          filePaths = new ArrayList<FilePath>();
          forbiddenFilePaths = new ArrayList<FilePath>();
          dynamicGerritProject = new GerritProject(type, text, branches, topics, filePaths, forbiddenFilePaths);
        } else if (SHORTNAME_BRANCH.equals(item)) { // Branch
          if (branches == null) {
            throw new ParseException("Line " + lineNr + ": attempt to use 'Branch' before 'Project'", lineNr);
          }
          Branch branch = new Branch(type, text);
          branches.add(branch);
          dynamicGerritProject.setBranches(branches);
        } else if (SHORTNAME_TOPIC.equals(item)) { // Topic
            if (topics == null) {
                throw new ParseException("Line " + lineNr + ": attempt to use 'Topic' before 'Project'", lineNr);
            }
            Topic topic = new Topic(type, text);
            topics.add(topic);
            dynamicGerritProject.setTopics(topics);
        } else if (SHORTNAME_FILE.equals(item)) { // FilePath
          if (filePaths == null) {
            throw new ParseException("Line " + lineNr + ": attempt to use 'FilePath' before 'Project'", lineNr);
          }
          FilePath filePath = new FilePath(type, text);
          filePaths.add(filePath);
          dynamicGerritProject.setFilePaths(filePaths);
        } else if (SHORTNAME_FORBIDDEN_FILE.equals(item)) { // ForbiddenFilePath
          if (forbiddenFilePaths == null) {
            throw new ParseException("Line " + lineNr + ": attempt to use 'ForbiddenFilePath' before 'Project'", lineNr);
          }
          FilePath filePath = new FilePath(type, text);
          forbiddenFilePaths.add(filePath);
          dynamicGerritProject.setForbiddenFilePaths(filePaths);
        }
      }

      // Finally stash the last project to the list
      if (dynamicGerritProject != null) {
View Full Code Here

        PowerMockito.when(ToGerritRunListener.getInstance()).thenReturn(listener);

        AbstractProject project = PowerMockito.mock(AbstractProject.class);
        when(project.isBuildable()).thenReturn(true);

        GerritProject gP = mock(GerritProject.class);
        doReturn(true).when(gP).isInteresting(any(String.class), any(String.class), any(String.class));
        when(gP.getFilePaths()).thenReturn(null);

        GerritTrigger trigger = Setup.createDefaultTrigger(null);
        when(project.getTrigger(GerritTrigger.class)).thenReturn(trigger);
        trigger.setGerritProjects(Collections.nCopies(1, gP));
        trigger.setEscapeQuotes(false);
View Full Code Here

        PowerMockito.when(ToGerritRunListener.getInstance()).thenReturn(listener);

        AbstractProject project = PowerMockito.mock(AbstractProject.class);
        when(project.isBuildable()).thenReturn(true);

        GerritProject gP = mock(GerritProject.class);
        doReturn(false).when(gP).isInteresting(any(String.class), any(String.class), any(String.class));
        when(gP.getFilePaths()).thenReturn(null);

        GerritTrigger trigger = Setup.createDefaultTrigger(null);
        when(project.getTrigger(GerritTrigger.class)).thenReturn(trigger);
        trigger.setGerritProjects(Collections.nCopies(1, gP));
        trigger.setEscapeQuotes(false);
View Full Code Here

        PowerMockito.when(ToGerritRunListener.getInstance()).thenReturn(listener);

        AbstractProject project = PowerMockito.mock(AbstractProject.class);
        when(project.isBuildable()).thenReturn(true);

        GerritProject gP = mock(GerritProject.class);
        doReturn(true).when(gP).isInteresting(any(String.class), any(String.class), any(String.class));
        when(gP.getFilePaths()).thenReturn(null);

        GerritTrigger trigger = Setup.createDefaultTrigger(null);
        when(project.getTrigger(GerritTrigger.class)).thenReturn(trigger);
        trigger.setGerritProjects(Collections.nCopies(1, gP));
        trigger.setEscapeQuotes(false);
View Full Code Here

TOP

Related Classes of com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.GerritProject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.