Source:
<code>public void shouldSaveAnIdentifierPool() throws Exception { long initialIdentifierSourceCount = getAllCount(); SimpleObject identifierSource = new SimpleObject(); identifierSource.add("name", "test identifier pool"); identifierSource.add("description", "test identifier pool"); identifierSource.add("batchSize", "500"); identifierSource.add("minPoolSize", "5"); identifierSource.add("sequential", "true"); identifierSource.add("refillWithScheduledTask", "true"); identifierSource.add("sourceUuid", getUuid()); identifierSource.add("identifierType", IDENTIFIER_TYPE_UUID); identifierSource.add("sourceType", IDENTIFIER_POOL_SOURCE_TYPE); String jsonIdentifierSource = new ObjectMapper().writeValueAsString(identifierSource); MockHttpServletRequest req = newPostRequest(getURI(), jsonIdentifierSource); handle(req); IdentifierPool generatedIdentifierSource = (IdentifierPool) service.getAllIdentifierSources(false).get(7); <START> assertEquals(generatedIdentifierSource.getName(), "test identifier pool"); <END> assertEquals(generatedIdentifierSource.getDescription(), "test identifier pool"); assertEquals(generatedIdentifierSource.getBatchSize(), Integer.parseInt("500")); assertEquals(generatedIdentifierSource.getMinPoolSize(), Integer.parseInt("5")); assertTrue(generatedIdentifierSource.isSequential()); assertTrue(generatedIdentifierSource.isRefillWithScheduledTask()); assertEquals(generatedIdentifierSource.getSource().getUuid(), getUuid()); assertEquals(initialIdentifierSourceCount + 1, getAllCount()); }</code><technical_language>Instead of fetching all, do getIdentifierSourceByUuid()</technical_language>

Target:
public void shouldSaveAnIdentifierPool() throws Exception { long initialIdentifierSourceCount = getAllCount(); SimpleObject identifierSource = new SimpleObject(); identifierSource.add("name", "test identifier pool"); identifierSource.add("description", "This is a test description for the identifier pool"); identifierSource.add("batchSize", "50"); identifierSource.add("minPoolSize", "5"); identifierSource.add("sequential", "true"); identifierSource.add("refill", "true"); identifierSource.add("sourceUuid", getUuid()); identifierSource.add("identifierType", IDENTIFIER_TYPE_UUID); identifierSource.add("sourceType", IDENTIFIER_POOL_SOURCE_TYPE); String jsonIdentifierSource = new ObjectMapper().writeValueAsString(identifierSource); MockHttpServletRequest req = newPostRequest(getURI(), jsonIdentifierSource); SimpleObject newIdentifierSource = deserialize(handle(req)); String newIdentifierSourceUuid = PropertyUtils.getProperty(newIdentifierSource, "uuid").toString(); IdentifierPool generatedIdentifierSource = (IdentifierPool) service.getIdentifierSourceByUuid(newIdentifierSourceUuid); assertEquals(newIdentifierSourceUuid, generatedIdentifierSource.getUuid()); assertEquals(generatedIdentifierSource.getName(), "test identifier pool"); assertEquals(generatedIdentifierSource.getDescription(), "This is a test description for the identifier pool"); assertEquals(generatedIdentifierSource.getBatchSize(), Integer.parseInt("50")); assertEquals(generatedIdentifierSource.getMinPoolSize(), Integer.parseInt("5")); assertEquals(generatedIdentifierSource.getSource().getUuid(), getUuid()); assertEquals(initialIdentifierSourceCount + 1, getAllCount()); }