List<ResourceTO> resources = resourceService.list(Long.valueOf(103));
assertEquals(4, resources.size());
// Retrieve a resource TO template.
ResourceTO resourceTO = resources.get(0);
// Make it new.
resourceTO.setName("newAbout103");
// Make it new.
connInstanceTO.setId(0);
connInstanceTO.setDisplayName("newDisplayName" + getUUIDString());
// ----------------------------------
// ----------------------------------
// Create a new connector instance.
// ----------------------------------
Response response = connectorService.create(connInstanceTO);
if (response.getStatus() != org.apache.http.HttpStatus.SC_CREATED) {
throw (RuntimeException) clientExceptionMapper.fromResponse(response);
}
connInstanceTO = getObject(response, ConnInstanceTO.class, connectorService);
assertNotNull(connInstanceTO);
assertTrue(connInstanceTO.getCapabilities().isEmpty());
long connId = connInstanceTO.getId();
// Link resourceTO to the new connector instance.
resourceTO.setConnectorId(connId);
// ----------------------------------
// ----------------------------------
// Check for connector instance update after resource creation.
// ----------------------------------
response = resourceService.create(resourceTO);
resourceTO = getObject(response, ResourceTO.class, resourceService);
assertNotNull(resourceTO);
resources = resourceService.list(connId);
assertEquals(1, resources.size());
// ----------------------------------
// ----------------------------------
// Check for spring bean.
// ----------------------------------
ConnInstanceTO connInstanceBean = connectorService.readByResource(resourceTO.getName());
assertNotNull(connInstanceBean);
assertTrue(connInstanceBean.getCapabilities().isEmpty());
// ----------------------------------
// ----------------------------------
// Check for spring bean update after connector instance update.
// ----------------------------------
connInstanceTO.addCapability(ConnectorCapability.SEARCH);
connectorService.update(connInstanceTO.getId(), connInstanceTO);
ConnInstanceTO actual = connectorService.read(connInstanceTO.getId());
assertNotNull(actual);
assertFalse(connInstanceTO.getCapabilities().isEmpty());
// check for spring bean update
connInstanceBean = connectorService.readByResource(resourceTO.getName());
assertFalse(connInstanceBean.getCapabilities().isEmpty());
// ----------------------------------
}