@SuppressWarnings("unchecked")
@Test
public void testServiceInsertConfigurationWithCollection_shouldInsertAndLoadConfigurations() throws Exception {
String id3 = UUID.randomUUID().toString();
ConnectorDescription desc3 = new ConnectorDescription();
desc3.setConnectorType("connectorType3");
desc3.setDomainType("domainTyp3");
desc3.getAttributes().put("attr3", "attr3");
Set<String> stringSet = new HashSet<String>();
stringSet.add("foo");
stringSet.add("bar");
desc3.getProperties().put("prop1", stringSet);
List<Integer> intList = new LinkedList<Integer>();
intList.add(5);
intList.add(33);
desc3.getProperties().put("prop2", intList);
ConnectorConfiguration conf3 = new ConnectorConfiguration(id3, desc3);
persist(conf3);
List<ConfigItem<ConnectorDescription>> loaded = service
.load(ImmutableMap.of(Constants.CONNECTOR_PERSISTENT_ID, id3));
assertThat(loaded.size(), is(1));
ConnectorConfiguration conf = (ConnectorConfiguration) loaded.get(0);
assertEquals(conf.getConnectorId(), id3);
ConnectorDescription loadedDesc = conf.getContent();
assertEquals(desc3.getAttributes(), loadedDesc.getAttributes());
Set<String> loadedSet = (HashSet<String>) loadedDesc.getProperties()
.get("prop1");
assertThat(loadedSet.size(), is(2));
assertTrue(loadedSet.containsAll(stringSet));
List<Integer> loadedList = (LinkedList<Integer>) loadedDesc
.getProperties().get("prop2");
assertThat(loadedList.size(), is(2));
assertTrue(loadedList.equals(intList));
}