Search in sources :

Example 1 with SystemPreferences

use of com.epam.pipeline.manager.preference.SystemPreferences in project cloud-pipeline by epam.

the class AggregatingToolScanManagerTest method testInit.

@Test
public void testInit() {
    AggregatingToolScanManager toolScanManager = new AggregatingToolScanManager();
    PreferenceManager preferenceManager = new PreferenceManager();
    PreferenceDao preferenceDao = Mockito.mock(PreferenceDao.class);
    SystemPreferences systemPreferences = Mockito.mock(SystemPreferences.class);
    Whitebox.setInternalState(preferenceManager, "preferenceDao", preferenceDao);
    Whitebox.setInternalState(preferenceManager, "messageHelper", messageHelper);
    Whitebox.setInternalState(preferenceManager, "systemPreferences", systemPreferences);
    Whitebox.setInternalState(toolScanManager, "preferenceManager", preferenceManager);
    toolScanManager.init();
    ClairService service = (ClairService) Whitebox.getInternalState(toolScanManager, "clairService");
    Assert.assertNull(service);
    Preference toolScanEnabled = SystemPreferences.DOCKER_SECURITY_TOOL_SCAN_ENABLED.toPreference();
    toolScanEnabled.setValue("true");
    when(preferenceDao.loadPreferenceByName(toolScanEnabled.getName())).thenReturn(toolScanEnabled);
    Preference clairRootUrl = SystemPreferences.DOCKER_SECURITY_TOOL_SCAN_CLAIR_ROOT_URL.toPreference();
    clairRootUrl.setValue("http://localhost:9000/");
    when(preferenceDao.loadPreferenceByName(clairRootUrl.getName())).thenReturn(clairRootUrl);
    preferenceManager.update(Arrays.asList(toolScanEnabled, clairRootUrl));
    service = (ClairService) Whitebox.getInternalState(toolScanManager, "clairService");
    Assert.assertNotNull(service);
}
Also used : ClairService(com.epam.pipeline.manager.docker.scan.clair.ClairService) Preference(com.epam.pipeline.entity.preference.Preference) SystemPreferences(com.epam.pipeline.manager.preference.SystemPreferences) PreferenceDao(com.epam.pipeline.dao.preference.PreferenceDao) PreferenceManager(com.epam.pipeline.manager.preference.PreferenceManager) Test(org.junit.Test)

Aggregations

PreferenceDao (com.epam.pipeline.dao.preference.PreferenceDao)1 Preference (com.epam.pipeline.entity.preference.Preference)1 ClairService (com.epam.pipeline.manager.docker.scan.clair.ClairService)1 PreferenceManager (com.epam.pipeline.manager.preference.PreferenceManager)1 SystemPreferences (com.epam.pipeline.manager.preference.SystemPreferences)1 Test (org.junit.Test)1