use of com.synopsys.integration.alert.common.rest.model.SettingsProxyModel in project hub-alert by blackducksoftware.
the class SettingsProxyTestActionTest method createDefaultSettingsProxyModel.
private SettingsProxyModel createDefaultSettingsProxyModel() {
SettingsProxyModel settingsProxyModel = new SettingsProxyModel();
settingsProxyModel.setName(AlertRestConstants.DEFAULT_CONFIGURATION_NAME);
settingsProxyModel.setProxyHost(HOST);
settingsProxyModel.setProxyPort(PORT);
settingsProxyModel.setProxyUsername(USERNAME);
settingsProxyModel.setIsProxyPasswordSet(false);
settingsProxyModel.setProxyPassword(PASSWORD);
return settingsProxyModel;
}
use of com.synopsys.integration.alert.common.rest.model.SettingsProxyModel in project hub-alert by blackducksoftware.
the class SettingsProxyCrudActionsTest method getOneTest.
@Test
public void getOneTest() {
UUID uuid = UUID.randomUUID();
SettingsProxyConfigurationRepository settingsProxyConfigurationRepository = Mockito.mock(SettingsProxyConfigurationRepository.class);
NonProxyHostsConfigurationRepository nonProxyHostsConfigurationRepository = Mockito.mock(NonProxyHostsConfigurationRepository.class);
Mockito.when(settingsProxyConfigurationRepository.findByName(AlertRestConstants.DEFAULT_CONFIGURATION_NAME)).thenReturn(Optional.of(createSettingsProxyConfigurationEntity(uuid)));
SettingsProxyConfigAccessor settingsProxyConfigAccessor = new SettingsProxyConfigAccessor(encryptionUtility, settingsProxyConfigurationRepository, nonProxyHostsConfigurationRepository);
SettingsProxyCrudActions configActions = new SettingsProxyCrudActions(authorizationManager, settingsProxyConfigAccessor, settingsProxyValidator, settingsDescriptorKey);
ActionResponse<SettingsProxyModel> actionResponse = configActions.getOne();
assertTrue(actionResponse.isSuccessful());
assertTrue(actionResponse.hasContent());
assertEquals(HttpStatus.OK, actionResponse.getHttpStatus());
assertModelObfuscated(actionResponse);
}
use of com.synopsys.integration.alert.common.rest.model.SettingsProxyModel in project hub-alert by blackducksoftware.
the class SettingsProxyCrudActionsTest method createTestConfigAlreadyExists.
@Test
public void createTestConfigAlreadyExists() {
UUID uuid = UUID.randomUUID();
SettingsProxyConfigurationRepository settingsProxyConfigurationRepository = Mockito.mock(SettingsProxyConfigurationRepository.class);
NonProxyHostsConfigurationRepository nonProxyHostsConfigurationRepository = Mockito.mock(NonProxyHostsConfigurationRepository.class);
Mockito.when(settingsProxyConfigurationRepository.existsByName(AlertRestConstants.DEFAULT_CONFIGURATION_NAME)).thenReturn(true);
SettingsProxyConfigAccessor settingsProxyConfigAccessor = new SettingsProxyConfigAccessor(encryptionUtility, settingsProxyConfigurationRepository, nonProxyHostsConfigurationRepository);
SettingsProxyCrudActions configActions = new SettingsProxyCrudActions(authorizationManager, settingsProxyConfigAccessor, settingsProxyValidator, settingsDescriptorKey);
ActionResponse<SettingsProxyModel> actionResponse = configActions.create(createSettingsProxyModel());
assertTrue(actionResponse.isError());
assertFalse(actionResponse.hasContent());
assertEquals(HttpStatus.BAD_REQUEST, actionResponse.getHttpStatus());
}
use of com.synopsys.integration.alert.common.rest.model.SettingsProxyModel in project hub-alert by blackducksoftware.
the class SettingsProxyCrudActionsTest method updateTest.
@Test
public void updateTest() {
UUID uuid = UUID.randomUUID();
SettingsProxyConfigurationRepository settingsProxyConfigurationRepository = Mockito.mock(SettingsProxyConfigurationRepository.class);
NonProxyHostsConfigurationRepository nonProxyHostsConfigurationRepository = Mockito.mock(NonProxyHostsConfigurationRepository.class);
SettingsProxyConfigurationEntity entity = createSettingsProxyConfigurationEntity(uuid);
Mockito.when(settingsProxyConfigurationRepository.findByName(AlertRestConstants.DEFAULT_CONFIGURATION_NAME)).thenReturn(Optional.of(entity));
Mockito.when(settingsProxyConfigurationRepository.existsByName(AlertRestConstants.DEFAULT_CONFIGURATION_NAME)).thenReturn(true);
Mockito.when(settingsProxyConfigurationRepository.save(Mockito.any())).thenReturn(entity);
Mockito.when(settingsProxyConfigurationRepository.getOne(uuid)).thenReturn(entity);
SettingsProxyConfigAccessor settingsProxyConfigAccessor = new SettingsProxyConfigAccessor(encryptionUtility, settingsProxyConfigurationRepository, nonProxyHostsConfigurationRepository);
SettingsProxyCrudActions configActions = new SettingsProxyCrudActions(authorizationManager, settingsProxyConfigAccessor, settingsProxyValidator, settingsDescriptorKey);
SettingsProxyModel settingsProxyModel = createSettingsProxyModel();
ActionResponse<SettingsProxyModel> actionResponse = configActions.update(settingsProxyModel);
Mockito.verify(nonProxyHostsConfigurationRepository).saveAll(Mockito.any());
assertTrue(actionResponse.isSuccessful());
assertTrue(actionResponse.hasContent());
assertEquals(HttpStatus.OK, actionResponse.getHttpStatus());
assertModelObfuscated(actionResponse);
}
use of com.synopsys.integration.alert.common.rest.model.SettingsProxyModel in project hub-alert by blackducksoftware.
the class SettingsProxyCrudActionsTest method createSettingsProxyModel.
private SettingsProxyModel createSettingsProxyModel() {
SettingsProxyModel settingsProxyModel = new SettingsProxyModel();
settingsProxyModel.setName(AlertRestConstants.DEFAULT_CONFIGURATION_NAME);
settingsProxyModel.setProxyHost(HOST);
settingsProxyModel.setProxyPort(PORT);
settingsProxyModel.setProxyUsername(USERNAME);
settingsProxyModel.setProxyPassword(PASSWORD);
return settingsProxyModel;
}
Aggregations