RM-3964: Component children test.

This commit is contained in:
Kristijan Conkas
2016-10-26 16:54:31 +01:00
parent 9efdc2834a
commit d9a6e04b6e
2 changed files with 25 additions and 7 deletions

View File

@@ -27,14 +27,10 @@ import org.springframework.stereotype.Component;
* @author Kristijan Conkas * @author Kristijan Conkas
* @since 1.0 * @since 1.0
*/ */
@Component
@Scope(value = "prototype")
//FIXME: Once the fields have been added the JsonIgnoreProperties annotation should be removed //FIXME: Once the fields have been added the JsonIgnoreProperties annotation should be removed
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class FilePlanComponentProperties public class FilePlanComponentProperties
{ {
// TODO: handling individual properties is tedious and error prone, how about @JsonGetter + @JsonSetter?
@JsonProperty(PROPERTIES_VITAL_RECORD_INDICATOR) @JsonProperty(PROPERTIES_VITAL_RECORD_INDICATOR)
private boolean vitalRecord; private boolean vitalRecord;

View File

@@ -27,9 +27,11 @@ import static org.springframework.http.HttpStatus.OK;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.NoSuchElementException;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
@@ -210,6 +212,7 @@ public class RecordCategoryTest extends BaseRestTest
// create subcategory as a child of rootCategory // create subcategory as a child of rootCategory
FilePlanComponent childCategory = createCategory(rootCategory.getId(), RandomData.getRandomAlphanumeric()); FilePlanComponent childCategory = createCategory(rootCategory.getId(), RandomData.getRandomAlphanumeric());
// child category created? // child category created?
assertNotNull(childCategory.getId()); assertNotNull(childCategory.getId());
} }
@@ -250,12 +253,31 @@ public class RecordCategoryTest extends BaseRestTest
FilePlanComponentsCollection apiChildren = filePlanComponentApi.listChildComponents(rootCategory.getId()); FilePlanComponentsCollection apiChildren = filePlanComponentApi.listChildComponents(rootCategory.getId());
restWrapper.assertStatusCodeIs(OK); restWrapper.assertStatusCodeIs(OK);
// check listed children against created list
List<FilePlanComponentEntry> childrenApi = apiChildren.getEntries(); List<FilePlanComponentEntry> childrenApi = apiChildren.getEntries();
childrenApi.forEach(c -> { childrenApi.forEach(c ->
//assertNotNull(c.getId()); {
FilePlanComponent filePlanComponent = c.getFilePlanComponent(); FilePlanComponent filePlanComponent = c.getFilePlanComponent();
assertNotNull(filePlanComponent.getId());
logger.info(c + " id=" + filePlanComponent.getId() + " name=" + filePlanComponent.getName() + " properties=" + filePlanComponent.getProperties()); logger.info(c + " id=" + filePlanComponent.getId() + " name=" + filePlanComponent.getName() + " properties=" + filePlanComponent.getProperties());
try
{
FilePlanComponent createdComponent = children.stream()
.filter(child -> child.getId().compareTo(filePlanComponent.getId()) == 0)
.findFirst()
.get();
// does returned object have the same contents as the created one?
assertEquals(createdComponent.getName(), filePlanComponent.getName());
assertEquals(createdComponent.getNodeType(), filePlanComponent.getNodeType());
assertEquals(createdComponent.getProperties().getTitle(), filePlanComponent.getProperties().getTitle());
}
catch (NoSuchElementException e)
{
fail("No child element for " + filePlanComponent.getId());
}
}); });
} }