Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure missing implementations for new SechubDataConfigurationUsageByName variants are detected automatically #3006

Open
de-jcup opened this issue Mar 14, 2024 · 0 comments

Comments

@de-jcup
Copy link
Member

de-jcup commented Mar 14, 2024

Situation

When #2847 was implemented, it took a long time to understand why an integration test did fail - the reason was, that the configuration model support is responsible for the decision, if source code is necessary or not - when not, the download will not start from PDS side...

It was not clear at a first glance that the implementation inside support was missing.

Wanted

If anybody extends something inside the configuration model in a way the configuration model support must be implemented, a test shall automatically fail and give a hint.

Solution

When #3005 has been implemented, we can extend the existing SecHubConfigurationModelSupportTest in following way:

          static Set<Class<? extends SechubDataConfigurationUsageByName> testedConfigClasses

	  @BeforeAll
	  void static init(){
		testedConfigClasses=new LinkedHashSet<>();
	  }
	  
          @Test
	  void source_necessary_for_SecHubWebScanApiConfiguration(){
		
		/* prepare */
		// ... Build model with SecHubWebScanApiConfiguration inside

		/* execute */
		// ...supportToTest....
		
		/* test ...*/
		// ... assertTrue(supportToTest.isSourceRequired(...))
		
		/* remember */
	        testedConfigClasses.add(SecHubWebScanApiConfiguration.class);
	  }
	  
	  
	  @AfterAll
	  static void assertAllConfigurationUsageImplementations() {
		List<Class<? extends SechubDataConfigurationUsageByName> classes = Reflections.getAllUsagesOf(SechubDataConfigurationUsageByName.class);
		
	        assertTrue(testConfigClasses.containsAll(classes);
		  
		List<Class<? extends SechubDataConfigurationUsageByName>> missing = new ArrayList<>();
		for(Class<? extends SechubDataConfigurationUsageByName> usage: classes){
		   if (!testConfigClasses.contains(usage)){
			missing.add(usage);
		   }
		}
		 
		if (usage.isEmpty(){
		     return;
		}
		fail("Some config classes are not tested: "+missing);
		  
           }
	  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant