Search in sources :

Example 1 with FarmersGrandson

use of org.alfresco.rest.framework.tests.api.mocks2.FarmersGrandson in project alfresco-remote-api by Alfresco.

the class InspectorTests method testUniqueIdAnnotation.

@Test
public void testUniqueIdAnnotation() {
    String uniqueId = ResourceInspector.findUniqueId(new Grass("34"));
    assertNull(uniqueId);
    uniqueId = ResourceInspector.findUniqueId(new Farmer("345"));
    assertNotNull(uniqueId);
    assertTrue("345".equals(uniqueId));
    // inherited classes are ok (with overidden unique id method)
    uniqueId = ResourceInspector.findUniqueId(new FarmersSon("567"));
    assertNotNull(uniqueId);
    assertTrue("567".equals(uniqueId));
    // inherited classes are ok (with overidden unique id method but @UniqueId annotation not specified)
    uniqueId = ResourceInspector.findUniqueId(new FarmersGrandson("12"));
    assertNotNull(uniqueId);
    assertTrue("12".equals(uniqueId));
    // More than 1 annotation should throw IllegalArgumentException
    try {
        uniqueId = ResourceInspector.findUniqueId(new FarmersDaughter("21"));
        fail("Should throw an InvalidArgumentException");
    } catch (IllegalArgumentException error) {
    // this is correct
    }
}
Also used : FarmersSon(org.alfresco.rest.framework.tests.api.mocks2.FarmersSon) FarmersGrandson(org.alfresco.rest.framework.tests.api.mocks2.FarmersGrandson) FarmersDaughter(org.alfresco.rest.framework.tests.api.mocks2.FarmersDaughter) Grass(org.alfresco.rest.framework.tests.api.mocks.Grass) Farmer(org.alfresco.rest.framework.tests.api.mocks.Farmer) Test(org.junit.Test)

Aggregations

Farmer (org.alfresco.rest.framework.tests.api.mocks.Farmer)1 Grass (org.alfresco.rest.framework.tests.api.mocks.Grass)1 FarmersDaughter (org.alfresco.rest.framework.tests.api.mocks2.FarmersDaughter)1 FarmersGrandson (org.alfresco.rest.framework.tests.api.mocks2.FarmersGrandson)1 FarmersSon (org.alfresco.rest.framework.tests.api.mocks2.FarmersSon)1 Test (org.junit.Test)1