use of org.wso2.carbon.apimgt.rest.api.core.dto.RegistrationSummaryDTO in project carbon-apimgt by wso2.
the class GatewaysApiServiceImplTestCase method gatewaysRegisterPostTest.
@Test
public void gatewaysRegisterPostTest() throws Exception {
APIMgtAdminServiceImpl adminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(adminService);
RegistrationDTO registrationDTO = Mockito.mock(RegistrationDTO.class);
LabelInfoDTO labelInfoDTO = Mockito.mock(LabelInfoDTO.class);
Mockito.when(registrationDTO.getLabelInfo()).thenReturn(labelInfoDTO);
RegistrationSummary registrationSummary = Mockito.mock(RegistrationSummary.class);
Mockito.when(adminService.getRegistrationSummary()).thenReturn(registrationSummary);
RegistrationSummary.AnalyticsInfo analyticsInfo = Mockito.mock(RegistrationSummary.AnalyticsInfo.class);
Mockito.when(registrationSummary.getAnalyticsInfo()).thenReturn(analyticsInfo);
RegistrationSummary.Credentials dssCredentials = Mockito.mock(RegistrationSummary.Credentials.class);
Mockito.when(registrationSummary.getAnalyticsInfo().getDasServerCredentials()).thenReturn(dssCredentials);
Mockito.when(dssCredentials.getUsername()).thenReturn(DSS_USERNAME);
Mockito.when(dssCredentials.getPassword()).thenReturn(DSS_PASSWORD);
RegistrationSummary.JWTInfo jwtInfo = Mockito.mock(RegistrationSummary.JWTInfo.class);
Mockito.when(registrationSummary.getJwtInfo()).thenReturn(jwtInfo);
RegistrationSummary.KeyManagerInfo keyManagerInfo = Mockito.mock(RegistrationSummary.KeyManagerInfo.class);
Mockito.when(registrationSummary.getKeyManagerInfo()).thenReturn(keyManagerInfo);
RegistrationSummary.Credentials keyManagerCredentials = Mockito.mock(RegistrationSummary.Credentials.class);
Mockito.when(registrationSummary.getKeyManagerInfo().getCredentials()).thenReturn(keyManagerCredentials);
Mockito.when(keyManagerCredentials.getUsername()).thenReturn(KEY_MANAGER_USERNAME);
Mockito.when(keyManagerCredentials.getPassword()).thenReturn(KEY_MANAGER_PASSWORD);
RegistrationSummary.ThrottlingInfo throttlingInfo = Mockito.mock(RegistrationSummary.ThrottlingInfo.class);
Mockito.when(registrationSummary.getThrottlingInfo()).thenReturn(throttlingInfo);
RegistrationSummary.ThrottlingInfo.DataPublisher dataPublisher = Mockito.mock(RegistrationSummary.ThrottlingInfo.DataPublisher.class);
Mockito.when(registrationSummary.getThrottlingInfo().getDataPublisher()).thenReturn(dataPublisher);
RegistrationSummary.Credentials throttlingServerCredentials = Mockito.mock(RegistrationSummary.Credentials.class);
Mockito.when(registrationSummary.getThrottlingInfo().getDataPublisher().getCredentials()).thenReturn(throttlingServerCredentials);
Mockito.when(throttlingServerCredentials.getUsername()).thenReturn(THROTTLE_SERVER_USERNAME);
Mockito.when(throttlingServerCredentials.getPassword()).thenReturn(THROTTLE_SERVER_PASSWORD);
RegistrationSummary.GoogleAnalyticsTrackingInfo googleAnalyticsTrackingInfo = Mockito.mock(RegistrationSummary.GoogleAnalyticsTrackingInfo.class);
Mockito.when(registrationSummary.getGoogleAnalyticsTrackingInfo()).thenReturn(googleAnalyticsTrackingInfo);
GatewaysApiServiceImpl gatewaysApiService = new GatewaysApiServiceImpl();
Response response = gatewaysApiService.gatewaysRegisterPost(registrationDTO, "application/json", getRequest());
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
CredentialsDTO analyticsInfoResponseCredentials = ((RegistrationSummaryDTO) response.getEntity()).getAnalyticsInfo().getCredentials();
CredentialsDTO keyManagerInfoResponseCredentials = ((RegistrationSummaryDTO) response.getEntity()).getKeyManagerInfo().getCredentials();
CredentialsDTO throttleServerInfoResponseCredentials = ((RegistrationSummaryDTO) response.getEntity()).getThrottlingInfo().getCredentials();
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
Assert.assertEquals(analyticsInfoResponseCredentials.getUsername(), DSS_USERNAME);
Assert.assertEquals(analyticsInfoResponseCredentials.getPassword(), DSS_PASSWORD);
Assert.assertEquals(keyManagerInfoResponseCredentials.getUsername(), KEY_MANAGER_USERNAME);
Assert.assertEquals(keyManagerInfoResponseCredentials.getPassword(), KEY_MANAGER_PASSWORD);
Assert.assertEquals(throttleServerInfoResponseCredentials.getUsername(), THROTTLE_SERVER_USERNAME);
Assert.assertEquals(throttleServerInfoResponseCredentials.getPassword(), THROTTLE_SERVER_PASSWORD);
}
use of org.wso2.carbon.apimgt.rest.api.core.dto.RegistrationSummaryDTO in project carbon-apimgt by wso2.
the class MappingUtil method toRegistrationSummaryDTO.
/**
* Converts the Gateway registration summary into RegistrationSummaryDTO
*
* @param registrationSummary the registration summary required by gateway
* @return RegistrationSummaryDTO
*/
public static RegistrationSummaryDTO toRegistrationSummaryDTO(RegistrationSummary registrationSummary) {
RegistrationSummaryDTO registrationSummaryDTO = new RegistrationSummaryDTO();
registrationSummaryDTO.setKeyManagerInfo(toKeyManagerInfoDTO(registrationSummary));
registrationSummaryDTO.setAnalyticsInfo(toAnalyticsDTO(registrationSummary));
registrationSummaryDTO.setJwTInfo(toJWTInfoDTO(registrationSummary));
registrationSummaryDTO.setThrottlingInfo(toThrottlingInfoDTO(registrationSummary));
registrationSummaryDTO.setGoogleAnalyticsTrackingInfo(toGoogleAnalyticsTrackingInfoDTO(registrationSummary.getGoogleAnalyticsTrackingInfo()));
return registrationSummaryDTO;
}
use of org.wso2.carbon.apimgt.rest.api.core.dto.RegistrationSummaryDTO in project carbon-apimgt by wso2.
the class MappingUtilTestCase method toRegistrationSummaryDTOTest.
@Test
public void toRegistrationSummaryDTOTest() {
RegistrationSummary registrationSummary = SampleTestObjectCreator.createUniqueRegistrationSummary();
RegistrationSummaryDTO registrationSummaryDTO = MappingUtil.toRegistrationSummaryDTO(registrationSummary);
Assert.assertEquals(registrationSummary.getKeyManagerInfo().getCredentials().getPassword(), registrationSummaryDTO.getKeyManagerInfo().getCredentials().getPassword());
Assert.assertEquals(registrationSummary.getKeyManagerInfo().getCredentials().getUsername(), registrationSummaryDTO.getKeyManagerInfo().getCredentials().getUsername());
Assert.assertEquals(registrationSummary.getKeyManagerInfo().getDcrEndpoint(), registrationSummaryDTO.getKeyManagerInfo().getDcrEndpoint());
Assert.assertEquals(registrationSummary.getKeyManagerInfo().getIntrospectEndpoint(), registrationSummaryDTO.getKeyManagerInfo().getIntrospectEndpoint());
Assert.assertEquals(registrationSummary.getKeyManagerInfo().getRevokeEndpoint(), registrationSummaryDTO.getKeyManagerInfo().getRevokeEndpoint());
Assert.assertEquals(registrationSummary.getKeyManagerInfo().getTokenEndpoint(), registrationSummaryDTO.getKeyManagerInfo().getTokenEndpoint());
Assert.assertEquals(registrationSummary.getAnalyticsInfo().getDasServerCredentials().getUsername(), registrationSummaryDTO.getAnalyticsInfo().getCredentials().getUsername());
Assert.assertEquals(registrationSummary.getAnalyticsInfo().getDasServerCredentials().getPassword(), registrationSummaryDTO.getAnalyticsInfo().getCredentials().getPassword());
Assert.assertEquals(registrationSummary.getAnalyticsInfo().getDasServerURL(), registrationSummaryDTO.getAnalyticsInfo().getServerURL());
Assert.assertEquals(Boolean.valueOf(registrationSummary.getAnalyticsInfo().isEnabled()), Boolean.valueOf(registrationSummaryDTO.getAnalyticsInfo().getEnabled()));
Assert.assertEquals(registrationSummary.getJwtInfo().getJwtHeader(), registrationSummaryDTO.getJwTInfo().getJwtHeader());
Assert.assertEquals(Boolean.valueOf(registrationSummary.getJwtInfo().isEnableJWTGeneration()), Boolean.valueOf(registrationSummaryDTO.getJwTInfo().getEnableJWTGeneration()));
Assert.assertEquals(registrationSummary.getThrottlingInfo().getDataPublisher().getReceiverURL(), registrationSummaryDTO.getThrottlingInfo().getServerURL());
Assert.assertEquals(registrationSummary.getThrottlingInfo().getDataPublisher().getCredentials().getPassword(), registrationSummaryDTO.getThrottlingInfo().getCredentials().getPassword());
Assert.assertEquals(registrationSummary.getThrottlingInfo().getDataPublisher().getCredentials().getUsername(), registrationSummaryDTO.getThrottlingInfo().getCredentials().getUsername());
}
Aggregations