test_class.declarator: connectionHandler
test_class.modifier: @MockBean
      private
test_class.original_string: @MockBean
      private ConnectionHandler connectionHandler;
test_class.type: ConnectionHandler
test_class.var_name: connectionHandler
test_class.declarator: buildService
test_class.modifier: @MockBean
      private
test_class.original_string: @MockBean
      private BuildService buildService;
test_class.type: BuildService
test_class.var_name: buildService
test_class.declarator: dashboardService
test_class.modifier: @MockBean
      private
test_class.original_string: @MockBean
      private DashboardService dashboardService;
test_class.type: DashboardService
test_class.var_name: dashboardService
test_class.declarator: eventHandler
test_class.modifier: private
test_class.original_string: private BuildEventHandler eventHandler;
test_class.type: BuildEventHandler
test_class.var_name: eventHandler
test_class.file: mirrorgate-api/src/test/java/com/bbva/arq/devops/ae/mirrorgate/cron/handler/BuildEventHandlerTest.java
test_class.identifier: BuildEventHandlerTest
test_case.body: @Test
      public void testBuildWithTeamMembersEvents() {
          final Dashboard dashboard1 = new Dashboard()
              .setName("dashboard1")
              .setCodeRepos(Arrays.asList(".*repo1.*", "http://repo2.git"))
              .setTeamMembers(Collections.singletonList("Atreyu"));
          final Dashboard dashboard2 = new Dashboard()
              .setName("dashboard2")
              .setCodeRepos(Arrays.asList(".*repo1.*", "http://repo4.git"))
              .setTeamMembers(Arrays.asList("Atreyu", "Gmork"));
  
          final BuildDTO build = TestObjectFactory.createBuildDTO()
              .setKeywords(Collections.singletonList("http://repo1.git"))
              .setCulprits(Collections.singletonList("Gmork"));
  
          final Event event = new Event().setCollectionId(build.getBuildUrl());
          final Set<String> dashboardIds = new HashSet<>(Arrays.asList(dashboard1.getName(), dashboard2.getName()));
  
          when(buildService.getBuildsByIds(anyList())).thenReturn(Collections.singletonList(build));
          when(dashboardService.getDashboardWithNames(anyList())).thenReturn(Arrays.asList(dashboard1, dashboard2));
  
          eventHandler.processEvents(Collections.singletonList(event), dashboardIds);
  
          verify(connectionHandler, times(0))
              .sendEventUpdateMessage(EventType.BUILD, dashboard1.getName());
          verify(connectionHandler, times(1))
              .sendEventUpdateMessage(EventType.BUILD, dashboard2.getName());
      }
test_case.class_method_signature: BuildEventHandlerTest.testBuildWithTeamMembersEvents()
test_case.full_signature: @Test public void testBuildWithTeamMembersEvents()
test_case.identifier: testBuildWithTeamMembersEvents
test_case.invocations: setTeamMembers setCodeRepos setName asList singletonList setTeamMembers setCodeRepos setName asList asList setCulprits setKeywords createBuildDTO singletonList singletonList setCollectionId getBuildUrl asList getName getName thenReturn when getBuildsByIds anyList singletonList thenReturn when getDashboardWithNames anyList asList processEvents singletonList sendEventUpdateMessage verify times getName sendEventUpdateMessage verify times getName
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testBuildWithTeamMembersEvents()
focal_class.declarator: connectionHandler
focal_class.modifier: private final
focal_class.original_string: private final ConnectionHandler connectionHandler;
focal_class.type: ConnectionHandler
focal_class.var_name: connectionHandler
focal_class.declarator: buildService
focal_class.modifier: private final
focal_class.original_string: private final BuildService buildService;
focal_class.type: BuildService
focal_class.var_name: buildService
focal_class.declarator: eventsHelper
focal_class.modifier: private final
focal_class.original_string: private final ProcessEventsHelper eventsHelper;
focal_class.type: ProcessEventsHelper
focal_class.var_name: eventsHelper
focal_class.file: mirrorgate-api/src/main/java/com/bbva/arq/devops/ae/mirrorgate/cron/handler/BuildEventHandler.java
focal_class.identifier: BuildEventHandler
focal_class.interfaces: implements EventHandler
focal_class.class_method_signature: BuildEventHandler.BuildEventHandler(
          final ConnectionHandler connectionHandler,
          final BuildService buildService,
          final ProcessEventsHelper eventsHelper
      )
focal_class.full_signature: @Autowired public  BuildEventHandler(
          final ConnectionHandler connectionHandler,
          final BuildService buildService,
          final ProcessEventsHelper eventsHelper
      )
focal_class.identifier: BuildEventHandler
focal_class.modifiers: @Autowired public
focal_class.parameters: (
          final ConnectionHandler connectionHandler,
          final BuildService buildService,
          final ProcessEventsHelper eventsHelper
      )
focal_class.signature:  BuildEventHandler(
          final ConnectionHandler connectionHandler,
          final BuildService buildService,
          final ProcessEventsHelper eventsHelper
      )
focal_class.class_method_signature: BuildEventHandler.processEvents(final List<Event> eventList, final Set<String> dashboardIds)
focal_class.full_signature: @Override public void processEvents(final List<Event> eventList, final Set<String> dashboardIds)
focal_class.identifier: processEvents
focal_class.modifiers: @Override public
focal_class.parameters: (final List<Event> eventList, final Set<String> dashboardIds)
focal_class.return: void
focal_class.signature: void processEvents(final List<Event> eventList, final Set<String> dashboardIds)
focal_method.body: @Override
      public void processEvents(final List<Event> eventList, final Set<String> dashboardIds) {
          final List<String> ids = eventList.stream()
              .map(Event::getCollectionId)
              .map(String.class::cast)
              .collect(Collectors.toList());
  
          if (ids.contains(null)) {
              connectionHandler.sendEventUpdateMessageToAll(EventType.BUILD);
          } else {
              final Iterable<BuildDTO> builds = buildService.getBuildsByIds(ids);
  
              final Predicate<Dashboard> filterDashboards = dashboard ->
                  StreamSupport
                      .stream(builds.spliterator(), false)
                      .anyMatch(build -> {
  
                          if (dashboard.getCodeRepos() == null || dashboard.getCodeRepos().isEmpty()) {
                              return false;
                          }
  
                          if (dashboard.getTeamMembers() != null && ! dashboard.getTeamMembers().isEmpty()
                              && ! CollectionUtils.containsAny(dashboard.getTeamMembers(), build.getCulprits())) {
                              return false;
                          }
  
                          return dashboard.getCodeRepos().stream().anyMatch(repo ->
                              build.getKeywords()
                                  .stream()
                                  .anyMatch(keyword -> Pattern.matches("^" + repo + "$", keyword))
                          );
                      });
  
              eventsHelper.processEvents(dashboardIds, filterDashboards, EventType.BUILD);
          }
      }
focal_method.class_method_signature: BuildEventHandler.processEvents(final List<Event> eventList, final Set<String> dashboardIds)
focal_method.full_signature: @Override public void processEvents(final List<Event> eventList, final Set<String> dashboardIds)
focal_method.identifier: processEvents
focal_method.invocations: collect map map stream toList contains sendEventUpdateMessageToAll getBuildsByIds anyMatch stream spliterator getCodeRepos isEmpty getCodeRepos getTeamMembers isEmpty getTeamMembers containsAny getTeamMembers getCulprits anyMatch stream getCodeRepos anyMatch stream getKeywords matches processEvents
focal_method.modifiers: @Override public
focal_method.parameters: (final List<Event> eventList, final Set<String> dashboardIds)
focal_method.return: void
focal_method.signature: void processEvents(final List<Event> eventList, final Set<String> dashboardIds)