mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-11 12:03:09 +00:00
DS-4224 Update unit test to comply with refactoring
This commit is contained in:
@@ -146,7 +146,7 @@ public class EntityServiceImplTest {
|
|||||||
relationshipList.add(relationship);
|
relationshipList.add(relationship);
|
||||||
|
|
||||||
// Mock the state of objects utilized in getRelationsByType() to meet the success criteria of an invocation
|
// Mock the state of objects utilized in getRelationsByType() to meet the success criteria of an invocation
|
||||||
when(relationshipService.findAll(context)).thenReturn(relationshipList);
|
when(relationshipService.findAll(context, -1, -1)).thenReturn(relationshipList);
|
||||||
when(relationship.getRelationshipType()).thenReturn(relationshipType);
|
when(relationship.getRelationshipType()).thenReturn(relationshipType);
|
||||||
when(relationshipType.getLeftwardType()).thenReturn("leftwardType");
|
when(relationshipType.getLeftwardType()).thenReturn("leftwardType");
|
||||||
when(relationshipType.getRightwardType()).thenReturn("rightwardType");
|
when(relationshipType.getRightwardType()).thenReturn("rightwardType");
|
||||||
@@ -178,8 +178,8 @@ public class EntityServiceImplTest {
|
|||||||
when(metadataValue.getValue()).thenReturn("testType");
|
when(metadataValue.getValue()).thenReturn("testType");
|
||||||
when(entity.getItem()).thenReturn(item);
|
when(entity.getItem()).thenReturn(item);
|
||||||
when(itemService.getMetadata(item, "relationship", "type", null, Item.ANY)).thenReturn(list);
|
when(itemService.getMetadata(item, "relationship", "type", null, Item.ANY)).thenReturn(list);
|
||||||
when(relationshipTypeDAO.findAll(context, RelationshipType.class)).thenReturn(relationshipTypeList);
|
when(relationshipTypeDAO.findAll(context, RelationshipType.class, -1, -1)).thenReturn(relationshipTypeList);
|
||||||
when(relationshipTypeService.findAll(context)).thenReturn(relationshipTypeList);
|
when(relationshipTypeService.findAll(context, -1, -1)).thenReturn(relationshipTypeList);
|
||||||
when(relationshipType.getLeftType()).thenReturn(leftType);
|
when(relationshipType.getLeftType()).thenReturn(leftType);
|
||||||
when(relationshipType.getRightType()).thenReturn(rightType);
|
when(relationshipType.getRightType()).thenReturn(rightType);
|
||||||
when(entityTypeService.findByEntityType(context, "value")).thenReturn(leftType);
|
when(entityTypeService.findByEntityType(context, "value")).thenReturn(leftType);
|
||||||
@@ -212,7 +212,7 @@ public class EntityServiceImplTest {
|
|||||||
when(itemService.getMetadata(any(), any(), any(), any(), any())).thenReturn(metsList);
|
when(itemService.getMetadata(any(), any(), any(), any(), any())).thenReturn(metsList);
|
||||||
when(entity.getItem()).thenReturn(item);
|
when(entity.getItem()).thenReturn(item);
|
||||||
when(entityType.getID()).thenReturn(0);
|
when(entityType.getID()).thenReturn(0);
|
||||||
when(relationshipTypeService.findAll(any())).thenReturn(relationshipTypeList);
|
when(relationshipTypeService.findAll(context, -1, -1)).thenReturn(relationshipTypeList);
|
||||||
when(relationshipType.getLeftType()).thenReturn(entityType);
|
when(relationshipType.getLeftType()).thenReturn(entityType);
|
||||||
when(entityService.getType(context, entity)).thenReturn(entityType);
|
when(entityService.getType(context, entity)).thenReturn(entityType);
|
||||||
when(entityTypeService.findByEntityType(any(), any())).thenReturn(entityType);
|
when(entityTypeService.findByEntityType(any(), any())).thenReturn(entityType);
|
||||||
@@ -242,7 +242,7 @@ public class EntityServiceImplTest {
|
|||||||
when(itemService.getMetadata(any(), any(), any(), any(), any())).thenReturn(metsList);
|
when(itemService.getMetadata(any(), any(), any(), any(), any())).thenReturn(metsList);
|
||||||
when(entity.getItem()).thenReturn(item);
|
when(entity.getItem()).thenReturn(item);
|
||||||
when(entityType.getID()).thenReturn(0);
|
when(entityType.getID()).thenReturn(0);
|
||||||
when(relationshipTypeService.findAll(any())).thenReturn(relationshipTypeList);
|
when(relationshipTypeService.findAll(context, -1, -1)).thenReturn(relationshipTypeList);
|
||||||
when(relationshipType.getRightType()).thenReturn(entityType);
|
when(relationshipType.getRightType()).thenReturn(entityType);
|
||||||
when(entityService.getType(context, entity)).thenReturn(entityType);
|
when(entityService.getType(context, entity)).thenReturn(entityType);
|
||||||
when(entityTypeService.findByEntityType(any(), any())).thenReturn(entityType);
|
when(entityTypeService.findByEntityType(any(), any())).thenReturn(entityType);
|
||||||
@@ -262,7 +262,7 @@ public class EntityServiceImplTest {
|
|||||||
|
|
||||||
// Mock the state of objects utilized in getRelationshipTypesByTypeName()
|
// Mock the state of objects utilized in getRelationshipTypesByTypeName()
|
||||||
// to meet the success criteria of the invocation
|
// to meet the success criteria of the invocation
|
||||||
when(relationshipTypeService.findAll(context)).thenReturn(list);
|
when(relationshipTypeService.findAll(context, -1, -1)).thenReturn(list);
|
||||||
when(relationshipType.getLeftwardType()).thenReturn("leftwardType");
|
when(relationshipType.getLeftwardType()).thenReturn("leftwardType");
|
||||||
when(relationshipType.getRightwardType()).thenReturn("rightwardType");
|
when(relationshipType.getRightwardType()).thenReturn("rightwardType");
|
||||||
|
|
||||||
|
@@ -66,7 +66,7 @@ public class RelationshipServiceImplTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testFindAll() throws Exception {
|
public void testFindAll() throws Exception {
|
||||||
// Mock DAO to return our mocked relationshipsList
|
// Mock DAO to return our mocked relationshipsList
|
||||||
when(relationshipDAO.findAll(context, Relationship.class)).thenReturn(relationshipsList);
|
when(relationshipDAO.findAll(context, Relationship.class, -1, -1)).thenReturn(relationshipsList);
|
||||||
// The reported Relationship(s) should match our relationshipsList
|
// The reported Relationship(s) should match our relationshipsList
|
||||||
assertEquals("TestFindAll 0", relationshipsList, relationshipService.findAll(context));
|
assertEquals("TestFindAll 0", relationshipsList, relationshipService.findAll(context));
|
||||||
}
|
}
|
||||||
@@ -96,11 +96,10 @@ public class RelationshipServiceImplTest {
|
|||||||
relationshipTest.add(getRelationship(cindy, hank, hasFather,0,0));
|
relationshipTest.add(getRelationship(cindy, hank, hasFather,0,0));
|
||||||
relationshipTest.add(getRelationship(fred, cindy, hasMother,0,0));
|
relationshipTest.add(getRelationship(fred, cindy, hasMother,0,0));
|
||||||
relationshipTest.add(getRelationship(bob, cindy, hasMother,1,0));
|
relationshipTest.add(getRelationship(bob, cindy, hasMother,1,0));
|
||||||
when(relationshipService.findByItem(context, cindy)).thenReturn(relationshipTest);
|
when(relationshipService.findByItem(context, cindy, -1, -1)).thenReturn(relationshipTest);
|
||||||
when(relationshipDAO.findByItem(context, cindy)).thenReturn(relationshipTest);
|
|
||||||
|
|
||||||
// Mock the state of objects utilized in findByItem() to meet the success criteria of the invocation
|
// Mock the state of objects utilized in findByItem() to meet the success criteria of the invocation
|
||||||
when(relationshipDAO.findByItem(context, cindy)).thenReturn(relationshipTest);
|
when(relationshipDAO.findByItem(context, cindy, -1, -1)).thenReturn(relationshipTest);
|
||||||
|
|
||||||
List<Relationship> results = relationshipService.findByItem(context, cindy);
|
List<Relationship> results = relationshipService.findByItem(context, cindy);
|
||||||
assertEquals("TestFindByItem 0", relationshipTest, results);
|
assertEquals("TestFindByItem 0", relationshipTest, results);
|
||||||
|
@@ -107,7 +107,7 @@ public class RelationshipTypeTest {
|
|||||||
mockedList.add(secondRelationshipType);
|
mockedList.add(secondRelationshipType);
|
||||||
|
|
||||||
// Mock DAO to return our mockedList
|
// Mock DAO to return our mockedList
|
||||||
when(relationshipTypeDAO.findAll(context, RelationshipType.class)).thenReturn(mockedList);
|
when(relationshipTypeDAO.findAll(context, RelationshipType.class, -1, -1)).thenReturn(mockedList);
|
||||||
|
|
||||||
// Invoke findAll()
|
// Invoke findAll()
|
||||||
List<RelationshipType> foundRelationshipTypes = relationshipTypeService.findAll(context);
|
List<RelationshipType> foundRelationshipTypes = relationshipTypeService.findAll(context);
|
||||||
@@ -124,7 +124,7 @@ public class RelationshipTypeTest {
|
|||||||
mockedList.add(firstRelationshipType);
|
mockedList.add(firstRelationshipType);
|
||||||
|
|
||||||
// Mock DAO to return our mockedList
|
// Mock DAO to return our mockedList
|
||||||
when(relationshipTypeDAO.findByLeftwardOrRightwardTypeName(any(), any())).thenReturn(mockedList);
|
when(relationshipTypeDAO.findByLeftwardOrRightwardTypeName(context, "mock", -1, -1)).thenReturn(mockedList);
|
||||||
|
|
||||||
// Invoke findByLeftwardOrRightwardTypeName()
|
// Invoke findByLeftwardOrRightwardTypeName()
|
||||||
List<RelationshipType> found = relationshipTypeService.findByLeftwardOrRightwardTypeName(context, "mock");
|
List<RelationshipType> found = relationshipTypeService.findByLeftwardOrRightwardTypeName(context, "mock");
|
||||||
@@ -142,10 +142,11 @@ public class RelationshipTypeTest {
|
|||||||
mockedList.add(firstRelationshipType);
|
mockedList.add(firstRelationshipType);
|
||||||
|
|
||||||
// Mock DAO to return our mockedList
|
// Mock DAO to return our mockedList
|
||||||
when(relationshipTypeDAO.findByEntityType(any(), any())).thenReturn(mockedList);
|
when(relationshipTypeDAO.findByEntityType(any(), any(), any(), any())).thenReturn(mockedList);
|
||||||
|
|
||||||
// Invoke findByEntityType()
|
// Invoke findByEntityType()
|
||||||
List<RelationshipType> found = relationshipTypeService.findByEntityType(context, mock(EntityType.class));
|
List<RelationshipType> found = relationshipTypeService
|
||||||
|
.findByEntityType(context, mock(EntityType.class), -1, -1);
|
||||||
|
|
||||||
// Assert that our expected list contains our expected RelationshipType and nothing more
|
// Assert that our expected list contains our expected RelationshipType and nothing more
|
||||||
assertThat(found, notNullValue());
|
assertThat(found, notNullValue());
|
||||||
|
@@ -71,7 +71,7 @@ public class RelationshipTypeRestController {
|
|||||||
HttpServletRequest request) throws SQLException {
|
HttpServletRequest request) throws SQLException {
|
||||||
Context context = ContextUtil.obtainContext(request);
|
Context context = ContextUtil.obtainContext(request);
|
||||||
EntityType entityType = entityTypeService.find(context, id);
|
EntityType entityType = entityTypeService.find(context, id);
|
||||||
List<RelationshipType> list = relationshipTypeService.findByEntityType(context, entityType);
|
List<RelationshipType> list = relationshipTypeService.findByEntityType(context, entityType, -1, -1);
|
||||||
|
|
||||||
List<RelationshipTypeRest> relationshipTypeRests = new LinkedList<>();
|
List<RelationshipTypeRest> relationshipTypeRests = new LinkedList<>();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user