-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
55 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 42 additions & 69 deletions
111
src/test/java/org/owasp/dsomm/metricca/analyzer/deserialization/ApplicationDirectorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,42 @@ | ||
//package org.owasp.dsomm.metricca.analyzer.deserialization; | ||
// | ||
//import org.junit.jupiter.api.BeforeEach; | ||
//import org.junit.jupiter.api.Test; | ||
//import org.mockito.Mock; | ||
//import org.mockito.MockitoAnnotations; | ||
//import org.owasp.dsomm.metricca.analyzer.deserialization.activity.Activity; | ||
// | ||
//import java.lang.reflect.Constructor; | ||
//import java.lang.reflect.Field; | ||
//import java.util.List; | ||
// | ||
//import static org.junit.jupiter.api.Assertions.assertTrue; | ||
// | ||
//public class ApplicationDirectorTest { | ||
// | ||
// private ApplicationDirector applicationDirector; | ||
// | ||
// @Mock | ||
// private YamlScanner yamlScanner; | ||
// | ||
// @BeforeEach | ||
// public void setup() { | ||
// MockitoAnnotations.openMocks(this); | ||
// } | ||
// | ||
// @BeforeEach | ||
// public void setUp() throws Exception { | ||
// Constructor<ApplicationDirector> constructor = ApplicationDirector.class.getDeclaredConstructor(); | ||
// constructor.setAccessible(true); | ||
// applicationDirector = constructor.newInstance(); | ||
// YamlScanner yamlScanner = new YamlScanner(); | ||
// setPrivateField(yamlScanner, "yamlApplicationFolderPath", "src/test/resources/test-all/definitions"); | ||
// setPrivateField(yamlScanner, "yamlSkeletonFilePath", "src/test/resources/test-all/skeleton.yaml"); | ||
// yamlScanner.getApplicationYamls(); | ||
// setPrivateField(this.applicationDirector, "yamlScanner", yamlScanner); | ||
// } | ||
// | ||
// private void setPrivateField(Object targetObject, String fieldName, Object valueToSet) { | ||
// try { | ||
// Field field = targetObject.getClass().getDeclaredField(fieldName); | ||
// field.setAccessible(true); | ||
// field.set(targetObject, valueToSet); | ||
// } catch (NoSuchFieldException | IllegalAccessException e) { | ||
// throw new RuntimeException(e); | ||
// } | ||
// } | ||
// | ||
// @Test | ||
// public void testApplicationsExists() throws Exception { | ||
// List<Application> actualApplications = applicationDirector.getApplications(); | ||
// assertTrue(actualApplications.size() > 0); | ||
// } | ||
// | ||
// @Test | ||
// public void testTeamActivitySecurityRequirementsExists() throws Exception { | ||
// List<Application> actualApplications = applicationDirector.getApplications(); | ||
// boolean foundSecurityRequirements = false; | ||
// for (Application application : actualApplications) { | ||
// for (Activity activity : application.getActivities()) { | ||
// if (activity.getName().equals("Security requirements")) { | ||
// foundSecurityRequirements = true; | ||
// break; | ||
// } | ||
// } | ||
// } | ||
// assertTrue(foundSecurityRequirements); | ||
// } | ||
//} | ||
package org.owasp.dsomm.metricca.analyzer.deserialization; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.Mock; | ||
import org.mockito.MockitoAnnotations; | ||
import org.owasp.dsomm.metricca.analyzer.ApplicationTest; | ||
import org.owasp.dsomm.metricca.analyzer.deserialization.activity.Activity; | ||
|
||
import java.lang.reflect.Constructor; | ||
import java.lang.reflect.Field; | ||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class ApplicationDirectorTest extends ApplicationTest { | ||
@BeforeEach | ||
public void setup() { | ||
MockitoAnnotations.openMocks(this); | ||
} | ||
|
||
@Test | ||
public void testApplicationsExists() throws Exception { | ||
List<Application> actualApplications = applicationDirector.getApplications(); | ||
assertTrue(actualApplications.size() > 0); | ||
} | ||
|
||
@Test | ||
public void testTeamActivitySecurityRequirementsExists() throws Exception { | ||
List<Application> actualApplications = applicationDirector.getApplications(); | ||
boolean foundSecurityRequirements = false; | ||
for (Application application : actualApplications) { | ||
for (Activity activity : application.getActivities()) { | ||
if (activity.getName().equals("Security requirements")) { | ||
foundSecurityRequirements = true; | ||
break; | ||
} | ||
} | ||
} | ||
assertTrue(foundSecurityRequirements); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters