GroupProviderPropertyConverter { public static String convertToExternalGroupId(String input, GroupProvider groupProvider) { final List<ConversionRule> converters = groupProvider.getGroupDecorators(); return convertProperty(PROPERTY_ID, input, converters); }  static boolean isGroupFromGroupProvider(String groupId, GroupProvider groupProvider); static String convertToExternalPersonId(String input, GroupProvider groupProvider); static String convertToSurfConextPersonId(String input, GroupProvider groupProvider); static String convertToExternalGroupId(String input, GroupProvider groupProvider); static String convertToSurfConextGroupId(String input, GroupProvider groupProvider); static String convertProperty(String propertyName, String propertyValue,
                                       List<ConversionRule> converters); static final String PROPERTY_ID; static final String PROPERTY_NAME; static final String PROPERTY_DESCRIPTION; }
@Test public void testConvertToExternalGroup_noRule() { String identifier = "group1"; String externalId = GroupProviderPropertyConverter.convertToExternalGroupId(identifier, groupProvider); assertEquals(identifier, externalId); }
@Test public void testConvertToExternalGroup_asIs() { String identifier = "group1"; final ConversionRule asIsConverter = getAsIsConverter(); groupProvider.addGroupDecorator(asIsConverter); String externalId = GroupProviderPropertyConverter.convertToExternalGroupId(identifier, groupProvider); assertEquals(identifier, externalId); }
@Test public void testConvertToExternalGroup_StripUrnCollab() { String identifier = "urn:collab:group:myuniversity.nl:testgroup"; ConversionRule conversionRule = new ConversionRule(); conversionRule.setPropertyName("id"); conversionRule.setSearchPattern("urn:collab:group:myuniversity.nl:(.+)"); conversionRule.setReplaceWith("$1"); groupProvider.addGroupDecorator(conversionRule); String externalId = GroupProviderPropertyConverter.convertToExternalGroupId(identifier, groupProvider); assertEquals("testgroup", externalId); }
@Test public void testConvertToSurfConextGroup_AddUrnCollab() { String externalIdentifier = "testgroup"; String scIdentifier = "urn:collab:group:myuniversity.nl:testgroup"; ConversionRule conversionRule = new ConversionRule(); conversionRule.setPropertyName("id"); conversionRule.setSearchPattern("(.+)"); conversionRule.setReplaceWith("urn:collab:group:myuniversity.nl:$1"); groupProvider.addGroupDecorator(conversionRule); String result = GroupProviderPropertyConverter.convertToExternalGroupId(externalIdentifier, groupProvider); assertEquals(scIdentifier, result); }