commit d88250ff3905370e45af579f518cd37ca11bbb01
Author: Jiri Trefil <badjokke@gmail.com>
Date:   Tue May 23 15:50:54 2023 +0200

    #10397 Opraveny testy na detekci

diff --git a/src/test/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/DetectionServiceImplementationTest.java b/src/test/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/DetectionServiceImplementationTest.java
index b344394..82a458f 100644
--- a/src/test/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/DetectionServiceImplementationTest.java
+++ b/src/test/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/DetectionServiceImplementationTest.java
@@ -1,9 +1,14 @@
 package cz.zcu.fav.kiv.antipatterndetectionapp.v2.service;
 
+import cz.zcu.fav.kiv.antipatterndetectionapp.model.AntiPattern;
+import cz.zcu.fav.kiv.antipatterndetectionapp.model.Project;
 import cz.zcu.fav.kiv.antipatterndetectionapp.model.QueryResult;
 import cz.zcu.fav.kiv.antipatterndetectionapp.model.QueryResultItem;
+import cz.zcu.fav.kiv.antipatterndetectionapp.repository.AntiPatternRepository;
+import cz.zcu.fav.kiv.antipatterndetectionapp.repository.ProjectRepository;
 import cz.zcu.fav.kiv.antipatterndetectionapp.v2.dials.UserModelStatusCodes;
 import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.Configuration;
+import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.User;
 import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.UserDetectionDto;
 import cz.zcu.fav.kiv.antipatterndetectionapp.v2.repository.ConfigRepository;
 import cz.zcu.fav.kiv.antipatterndetectionapp.v2.repository.UserRepository;
@@ -13,6 +18,7 @@ import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.boot.test.mock.mockito.MockBean;
 
 import java.util.List;
+import java.util.Optional;
 
 import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.ArgumentMatchers.any;
@@ -24,42 +30,16 @@ public class DetectionServiceImplementationTest {
     DetectionService detectionService;
     @MockBean
     private ConfigRepository configRepository;
-
     private final Configuration mockConfiguration = new Configuration
             ("{      \"configuration\": [          {              \"antiPattern\": \"TooLongSprint\",              \"thresholds\": [                  {                      \"thresholdName\": \"maxIterationLength\",                      \"value\": \"21\"                  },                  {                      \"thresholdName\": \"maxNumberOfTooLongIterations\",                      \"value\": \"0\"                  }              ]          },          {              \"antiPattern\": \"VaryingSprintLength\",              \"thresholds\": [                  {                      \"thresholdName\": \"maxDaysDifference\",                      \"value\": \"7\"                  },                  {                      \"thresholdName\": \"maxIterationChanged\",                      \"value\": \"1\"                  }              ]          },          {              \"antiPattern\": \"BusinessAsUsual\",              \"thresholds\": [                  {                      \"thresholdName\": \"divisionOfIterationsWithRetrospective\",                      \"value\": \"66.66f\"                  },                  {                      \"thresholdName\": \"searchSubstringsWithRetrospective\",                      \"value\": \"%retr%||%revi%||%week%scrum%\"                  }              ]          },          {              \"antiPattern\": \"SpecifyNothing\",              \"thresholds\": [                  {                      \"thresholdName\": \"minNumberOfWikiPagesWithSpecification\",                      \"value\": \"1\"                  },                  {                      \"thresholdName\": \"minNumberOfActivitiesWithSpecification\",                      \"value\": \"1\"                  },                  {                      \"thresholdName\": \"minAvgLengthOfActivityDescription\",                      \"value\": \"150\"                  },                  {                      \"thresholdName\": \"searchSubstringsWithProjectSpecification\",                      \"value\": \"%dsp%||%specifikace%||%specification%||%vize%proj%||%vize%produ%\"                  }              ]          },          {              \"antiPattern\": \"RoadToNowhere\",              \"thresholds\": [                  {                      \"thresholdName\": \"minNumberOfWikiPagesWithProjectPlan\",                      \"value\": \"1\"                  },                  {                      \"thresholdName\": \"minNumberOfActivitiesWithProjectPlan\",                      \"value\": \"1\"                  },                  {                      \"thresholdName\": \"searchSubstringsWithProjectPlan\",                      \"value\": \"%plán projektu%||%project plan%||%plan project%||%projektový plán%\"                  }              ]          },          {              \"antiPattern\": \"LongOrNonExistentFeedbackLoops\",              \"thresholds\": [                  {                      \"thresholdName\": \"divisionOfIterationsWithFeedbackLoop\",                      \"value\": \"50.00f\"                  },                  {                      \"thresholdName\": \"maxGapBetweenFeedbackLoopRate\",                      \"value\": \"2f\"                  },                  {                      \"thresholdName\": \"searchSubstringsWithFeedbackLoop\",                      \"value\": \"%schůz%zákazník%||%předvedení%zákazník%||%zákazn%demo%||%schůz%zadavat%||%inform%schůz%||%zákazn%||%zadavatel%\"                  }              ]          },          {              \"antiPattern\": \"NinetyNinetyRule\",              \"thresholds\": [                  {                      \"thresholdName\": \"maxDivisionRange\",                      \"value\": \"1.25f\"                  },                  {                      \"thresholdName\": \"maxBadDivisionLimit\",                      \"value\": \"2\"                  }              ]          },          {              \"antiPattern\": \"UnknownPoster\",              \"thresholds\": [                  {                      \"thresholdName\": \"searchSubstringsInvalidNames\",                      \"value\": \"%unknown%||%anonym%\"                  }              ]          },          {              \"antiPattern\": \"BystanderApathy\",              \"thresholds\": [                  {                      \"thresholdName\": \"searchSubstringsInvalidContributors\",                      \"value\": \"%dependabot%\"                  },                  {                      \"thresholdName\": \"maximumPercentageOfTasksWithoutTeamwork\",                      \"value\": \"30f\"                  }              ]          },          {              \"antiPattern\": \"YetAnotherProgrammer\",              \"thresholds\": [                  {                      \"thresholdName\": \"maxNumberOfNewContributors\",                      \"value\": \"5\"                  },                  {                      \"thresholdName\": \"numberOfFirstMonthsWithoutDetection\",                      \"value\": \"2\"                  }              ]          }      ]  }",
                     "N","mockName",null);
-    //[JT] test for detection which is a valid input and anti patterns should not be detected in the project
-    @Test
-    public void validDetectionTestNotDetected() {
-        final UserDetectionDto userDetectionDtoMockNotDetected = new UserDetectionDto("foo",1,new String[]{"2"},new String[]{"3"});
 
-        when(configRepository.findConfigurationById(1)).thenReturn(mockConfiguration);
-        List<QueryResult> results = detectionService.analyze(userDetectionDtoMockNotDetected);
-        //only 1 project is being analyzed in the test, therefore only index 0 contains a value
-        QueryResult queryResult = results.get(0);
-        List<QueryResultItem> queryResultItems = queryResult.getQueryResultItems();
-        //again only one is being used in the test - only the first index contains value
-        QueryResultItem queryItem = queryResultItems.get(0);
-        assertFalse(queryItem.isDetected());
-    }
-    //test for valid request - anti pattern should be detected
-    @Test
-    public void validDetectionTestDetected() {
-        final UserDetectionDto userDetectionDtoMockDetected = new UserDetectionDto("foo",1,new String[]{"1"},new String[]{"1"});
-        when(configRepository.findConfigurationById(1)).thenReturn(mockConfiguration);
-        List<QueryResult> results = detectionService.analyze(userDetectionDtoMockDetected);
-        //only 1 project is being analyzed in the test, therefore only index 0 contains a value
-        QueryResult queryResult = results.get(0);
-        List<QueryResultItem> queryResultItems = queryResult.getQueryResultItems();
-        //again only one is being used in the test - only the first index contains value
-        QueryResultItem queryItem = queryResultItems.get(0);
-        assertTrue(queryItem.isDetected());
-    }
     //no projects provided in request - incorrect request
     @Test
     public void invalidProjectParameterDetection() {
         final UserDetectionDto userDetectionDtoMockInvalid = new UserDetectionDto("foo",1,new String[]{},new String[]{"1"});
         //request is invalid
+
         when(configRepository.findConfigurationById(1)).thenReturn(mockConfiguration);
         List<QueryResult> results = detectionService.analyze(userDetectionDtoMockInvalid);
         assertEquals(0,results.size());
