Java Code Examples for org.wso2.carbon.registry.core.Resource#setProperties()
The following examples show how to use
org.wso2.carbon.registry.core.Resource#setProperties() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SAMLSSOServiceProviderDAOTest.java From carbon-identity-framework with Apache License 2.0 | 6 votes |
@Test(dataProvider = "ResourceToObjectData") public void testAddServiceProvider(Object paramMapObj) throws Exception { Properties properties = new Properties(); properties.putAll((Map<?, ?>) paramMapObj); Resource dummyResource = new ResourceImpl(); dummyResource.setProperties(properties); SAMLSSOServiceProviderDO serviceProviderDO = objUnderTest.resourceToObject(dummyResource); ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); String expectedPath = getPath(dummyResource .getProperty(IdentityRegistryResources.PROP_SAML_SSO_ISSUER)); if (StringUtils.isNotBlank(serviceProviderDO.getIssuerQualifier())) { expectedPath = getPath(dummyResource.getProperty(IdentityRegistryResources.PROP_SAML_SSO_ISSUER) + IdentityRegistryResources.QUALIFIER_ID + dummyResource.getProperty(IdentityRegistryResources. PROP_SAML_SSO_ISSUER_QUALIFIER)); } objUnderTest.addServiceProvider(serviceProviderDO); verify(mockRegistry).put(captor.capture(), any(Resource.class)); assertEquals(captor.getValue(), expectedPath, "Resource is not added at correct path"); }
Example 2
Source File: SAMLSSOServiceProviderDAOTest.java From carbon-identity-framework with Apache License 2.0 | 6 votes |
@Test public void testGetServiceProvider() throws Exception { mockStatic(IdentityTenantUtil.class); RealmService mockRealmService = mock(RealmService.class); TenantManager mockTenantManager = mock(TenantManager.class); when(IdentityTenantUtil.getRealmService()).thenReturn(mockRealmService); when(mockRealmService.getTenantManager()).thenReturn(mockTenantManager); when(mockTenantManager.getDomain(anyInt())).thenReturn("test.com"); Properties dummyResourceProperties = new Properties(); dummyResourceProperties.putAll(dummyBasicProperties); Resource dummyResource = new ResourceImpl(); dummyResource.setProperties(dummyResourceProperties); String path = getPath(dummyResource.getProperty(IdentityRegistryResources.PROP_SAML_SSO_ISSUER)); when(mockRegistry.resourceExists(path)).thenReturn(true); when(mockRegistry.get(path)).thenReturn(dummyResource); SAMLSSOServiceProviderDO serviceProviderDO = objUnderTest.getServiceProvider(dummyResource.getProperty (IdentityRegistryResources.PROP_SAML_SSO_ISSUER)); assertEquals(serviceProviderDO.getTenantDomain(), "test.com", "Retrieved resource's tenant domain mismatch"); }
Example 3
Source File: SAMLSSOServiceProviderDAOTest.java From carbon-identity-framework with Apache License 2.0 | 5 votes |
@Test public void testGetServiceProviders() throws Exception { when(mockRegistry.resourceExists(IdentityRegistryResources.SAML_SSO_SERVICE_PROVIDERS)).thenReturn(true); Resource collection = new CollectionImpl(); String[] paths = new String[]{ getPath("DummyIssuer"), getPath("DummyAdvIssuer"), getPath("https://example.com/url?abc") }; Properties dummyResourceProperties = new Properties(); dummyResourceProperties.putAll(dummyBasicProperties); Resource dummyResource = new ResourceImpl(); dummyResource.setProperties(dummyResourceProperties); Properties dummyAdvProperties = new Properties(); dummyAdvProperties.putAll((Map<?, ?>) dummyAdvProperties); Resource dummyAdvResource = new ResourceImpl(); dummyAdvResource.setProperties(dummyAdvProperties); Properties urlBasedIssuerResourceProperties = new Properties(); urlBasedIssuerResourceProperties.putAll((Map<?, ?>) urlBasedIssuerResourceProperties); Resource urlBasedIssuerResource = new ResourceImpl(); urlBasedIssuerResource.setProperties(urlBasedIssuerResourceProperties); Resource[] spResources = new Resource[]{dummyResource, dummyAdvResource, urlBasedIssuerResource}; collection.setContent(paths); when(mockRegistry.get(IdentityRegistryResources.SAML_SSO_SERVICE_PROVIDERS)).thenReturn(collection); when(mockRegistry.get(paths[0])).thenReturn(spResources[0]); when(mockRegistry.get(paths[1])).thenReturn(spResources[1]); when(mockRegistry.get(paths[2])).thenReturn(spResources[2]); when(mockRegistry.resourceExists(paths[0])).thenReturn(true); when(mockRegistry.resourceExists(paths[1])).thenReturn(true); when(mockRegistry.resourceExists(paths[2])).thenReturn(true); SAMLSSOServiceProviderDO[] serviceProviders = objUnderTest.getServiceProviders(); assertEquals(serviceProviders.length, 3, "Should have returned 3 service providers."); }
Example 4
Source File: SAMLSSOServiceProviderDAOTest.java From carbon-identity-framework with Apache License 2.0 | 5 votes |
@Test public void testUploadServiceProvider() throws Exception { setUpResources(); Properties properties = new Properties(); properties.putAll(dummyBasicProperties); Resource dummyResource = new ResourceImpl(); dummyResource.setProperties(properties); String expectedPath = getPath(dummyResource .getProperty(IdentityRegistryResources.PROP_SAML_SSO_ISSUER)); when(mockRegistry.resourceExists(expectedPath)).thenReturn(false); SAMLSSOServiceProviderDO serviceProviderDO = objUnderTest.resourceToObject(dummyResource); assertEquals(objUnderTest.uploadServiceProvider(serviceProviderDO), serviceProviderDO, "Same resource should" + " have returned after successful upload."); }
Example 5
Source File: SAMLSSOServiceProviderDAOTest.java From carbon-identity-framework with Apache License 2.0 | 5 votes |
@Test(expectedExceptions = IdentityException.class) public void testUploadExistingServiceProvider() throws Exception { setUpResources(); Properties properties = new Properties(); properties.putAll(dummyAdvProperties); Resource dummyResource = new ResourceImpl(); dummyResource.setProperties(properties); String expectedPath = getPath(dummyResource .getProperty(IdentityRegistryResources.PROP_SAML_SSO_ISSUER)); when(mockRegistry.resourceExists(expectedPath)).thenReturn(true); SAMLSSOServiceProviderDO serviceProviderDO = objUnderTest.resourceToObject(dummyResource); objUnderTest.uploadServiceProvider(serviceProviderDO); fail("Uploading an existing SP should have failed"); }