Search in sources :

Example 11 with GroupIdRecord

use of org.orcid.jaxb.model.groupid_v2.GroupIdRecord in project ORCID-Source by ORCID.

the class ActivityValidatorTest method validateGroupId_validTest.

/**
     * VALIDATE GROUP ID RECORD
     * */
@Test
public void validateGroupId_validTest() {
    SourceEntity source = mock(SourceEntity.class);
    when(source.getSourceName()).thenReturn("source name");
    GroupIdRecord g = getGroupIdRecord();
    activityValidator.validateGroupIdRecord(g, true, source);
}
Also used : SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) GroupIdRecord(org.orcid.jaxb.model.groupid_v2.GroupIdRecord) Test(org.junit.Test)

Example 12 with GroupIdRecord

use of org.orcid.jaxb.model.groupid_v2.GroupIdRecord in project ORCID-Source by ORCID.

the class Api2_0_rc4_LastModifiedDatesHelper method calculateLastModified.

public static void calculateLastModified(GroupIdRecords groupIdRecords) {
    if (groupIdRecords != null && groupIdRecords.getGroupIdRecord() != null && !groupIdRecords.getGroupIdRecord().isEmpty()) {
        LastModifiedDate latest = null;
        for (GroupIdRecord groupid : groupIdRecords.getGroupIdRecord()) {
            if (groupid.getLastModifiedDate() != null && groupid.getLastModifiedDate().after(latest)) {
                latest = groupid.getLastModifiedDate();
            }
        }
        groupIdRecords.setLastModifiedDate(latest);
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_rc4.LastModifiedDate) GroupIdRecord(org.orcid.jaxb.model.groupid_rc4.GroupIdRecord)

Example 13 with GroupIdRecord

use of org.orcid.jaxb.model.groupid_v2.GroupIdRecord in project ORCID-Source by ORCID.

the class MapperFacadeFactory method getGroupIdRecordMapperFacade.

public MapperFacade getGroupIdRecordMapperFacade() {
    MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
    ClassMapBuilder<GroupIdRecord, GroupIdRecordEntity> classMap = mapperFactory.classMap(GroupIdRecord.class, GroupIdRecordEntity.class);
    addV2CommonFields(classMap);
    registerSourceConverters(mapperFactory, classMap);
    classMap.field("name", "groupName");
    classMap.field("groupId", "groupId");
    classMap.field("description", "groupDescription");
    classMap.field("type", "groupType");
    classMap.register();
    return mapperFactory.getMapperFacade();
}
Also used : GroupIdRecord(org.orcid.jaxb.model.groupid_v2.GroupIdRecord) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) GroupIdRecordEntity(org.orcid.persistence.jpa.entities.GroupIdRecordEntity)

Example 14 with GroupIdRecord

use of org.orcid.jaxb.model.groupid_v2.GroupIdRecord in project ORCID-Source by ORCID.

the class ActivityValidatorTest method getGroupIdRecord.

public GroupIdRecord getGroupIdRecord() {
    GroupIdRecord g = new GroupIdRecord();
    g.setDescription("description");
    g.setGroupId("orcid-generated:0123456789");
    g.setName("group-name");
    g.setType("group-type");
    return g;
}
Also used : GroupIdRecord(org.orcid.jaxb.model.groupid_v2.GroupIdRecord)

Example 15 with GroupIdRecord

use of org.orcid.jaxb.model.groupid_v2.GroupIdRecord in project ORCID-Source by ORCID.

the class ActivityValidatorTest method validateGroupId_invalidGroupIdTest.

@Test(expected = OrcidValidationException.class)
public void validateGroupId_invalidGroupIdTest() {
    SourceEntity source = mock(SourceEntity.class);
    when(source.getSourceName()).thenReturn("source name");
    GroupIdRecord g = getGroupIdRecord();
    g.setGroupId("invalid");
    activityValidator.validateGroupIdRecord(g, true, source);
}
Also used : SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) GroupIdRecord(org.orcid.jaxb.model.groupid_v2.GroupIdRecord) Test(org.junit.Test)

Aggregations

GroupIdRecord (org.orcid.jaxb.model.groupid_v2.GroupIdRecord)22 Test (org.junit.Test)12 DBUnitTest (org.orcid.test.DBUnitTest)4 Response (javax.ws.rs.core.Response)3 BaseTest (org.orcid.core.BaseTest)3 DuplicatedGroupIdRecordException (org.orcid.core.exception.DuplicatedGroupIdRecordException)3 GroupIdRecordNotFoundException (org.orcid.core.exception.GroupIdRecordNotFoundException)3 InvalidPutCodeException (org.orcid.core.exception.InvalidPutCodeException)3 OrcidValidationException (org.orcid.core.exception.OrcidValidationException)3 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)3 GroupIdRecordEntity (org.orcid.persistence.jpa.entities.GroupIdRecordEntity)3 ClientResponse (com.sun.jersey.api.client.ClientResponse)2 URISyntaxException (java.net.URISyntaxException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 LastModifiedDate (org.orcid.jaxb.model.common_v2.LastModifiedDate)2 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)2 IOException (java.io.IOException)1 URI (java.net.URI)1 AccessControlException (java.security.AccessControlException)1