use of org.orcid.jaxb.model.record_rc3.Keyword in project ORCID-Source by ORCID.
the class ValidateV2_1SamplesTest method testUnmarshallKeyword.
@Test
public void testUnmarshallKeyword() throws SAXException, URISyntaxException {
Keywords keywords = (Keywords) unmarshallFromPath("/record_2.1/samples/read_samples/keywords-2.1.xml", Keywords.class, "/record_2.1/keyword-2.1.xsd");
assertNotNull(keywords);
assertNotNull(keywords.getKeywords());
assertEquals(2, keywords.getKeywords().size());
for (Keyword keyword : keywords.getKeywords()) {
assertThat(keyword.getContent(), anyOf(is("keyword1"), is("keyword2")));
assertThat(keyword.getPutCode(), anyOf(is(Long.valueOf(1)), is(Long.valueOf(2))));
assertEquals(Visibility.PUBLIC.value(), keyword.getVisibility().value());
assertNotNull(keyword.getCreatedDate());
assertNotNull(keyword.getLastModifiedDate());
assertNotNull(keyword.getSource());
validateSourceInHttps(keyword.getSource());
assertEquals("8888-8888-8888-8880", keyword.getSource().retrieveSourcePath());
}
Keyword keyword = (Keyword) unmarshallFromPath("/record_2.1/samples/read_samples/keyword-2.1.xml", Keyword.class);
assertNotNull(keyword);
assertEquals("keyword1", keyword.getContent());
assertEquals(Long.valueOf(1), keyword.getPutCode());
assertEquals(Visibility.PUBLIC.value(), keyword.getVisibility().value());
assertNotNull(keyword.getCreatedDate());
assertNotNull(keyword.getLastModifiedDate());
assertNotNull(keyword.getSource());
validateSourceInHttps(keyword.getSource());
assertEquals("8888-8888-8888-8880", keyword.getSource().retrieveSourcePath());
}
use of org.orcid.jaxb.model.record_rc3.Keyword in project ORCID-Source by ORCID.
the class ValidateV2_1SamplesTest method unmarshallFromPath.
private Object unmarshallFromPath(String path, Class<?> type, String schemaPath) throws SAXException, URISyntaxException {
try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
Object obj = unmarshall(reader, type, schemaPath);
Object result = null;
if (ResearcherUrls.class.equals(type)) {
result = (ResearcherUrls) obj;
} else if (ResearcherUrl.class.equals(type)) {
result = (ResearcherUrl) obj;
} else if (PersonalDetails.class.equals(type)) {
result = (PersonalDetails) obj;
} else if (PersonExternalIdentifier.class.equals(type)) {
result = (PersonExternalIdentifier) obj;
} else if (PersonExternalIdentifiers.class.equals(type)) {
result = (PersonExternalIdentifiers) obj;
} else if (Biography.class.equals(type)) {
result = (Biography) obj;
} else if (Name.class.equals(type)) {
result = (Name) obj;
} else if (CreditName.class.equals(type)) {
result = (CreditName) obj;
} else if (OtherName.class.equals(type)) {
result = (OtherName) obj;
} else if (OtherNames.class.equals(type)) {
result = (OtherNames) obj;
} else if (Keywords.class.equals(type)) {
result = (Keywords) obj;
} else if (Keyword.class.equals(type)) {
result = (Keyword) obj;
} else if (Addresses.class.equals(type)) {
result = (Addresses) obj;
} else if (Address.class.equals(type)) {
result = (Address) obj;
} else if (Emails.class.equals(type)) {
result = (Emails) obj;
} else if (Email.class.equals(type)) {
result = (Email) obj;
} else if (Person.class.equals(type)) {
result = (Person) obj;
} else if (Deprecated.class.equals(type)) {
result = (Deprecated) obj;
} else if (Preferences.class.equals(type)) {
result = (Preferences) obj;
} else if (History.class.equals(type)) {
result = (History) obj;
} else if (Record.class.equals(type)) {
result = (Record) obj;
} else if (ActivitiesSummary.class.equals(type)) {
result = (ActivitiesSummary) obj;
} else if (Works.class.equals(type)) {
result = (Works) obj;
}
return result;
} catch (IOException e) {
throw new RuntimeException("Error reading notification from classpath", e);
}
}
use of org.orcid.jaxb.model.record_rc3.Keyword in project ORCID-Source by ORCID.
the class PublicV2ApiServiceDelegatorTest method testViewKeyword.
@Test
public void testViewKeyword() {
Response response = serviceDelegator.viewKeyword(ORCID, 9L);
assertNotNull(response);
Keyword keyword = (Keyword) response.getEntity();
assertNotNull(keyword);
assertNotNull(keyword.getLastModifiedDate());
assertNotNull(keyword.getLastModifiedDate().getValue());
assertEquals(Long.valueOf(9), keyword.getPutCode());
assertEquals("PUBLIC", keyword.getContent());
assertEquals(Visibility.PUBLIC.value(), keyword.getVisibility().value());
assertEquals("/0000-0000-0000-0003/keywords/9", keyword.getPath());
assertEquals("APP-5555555555555555", keyword.getSource().retrieveSourcePath());
}
use of org.orcid.jaxb.model.record_rc3.Keyword in project ORCID-Source by ORCID.
the class PublicV2ApiServiceDelegatorTest method testViewKeywords.
@Test
public void testViewKeywords() {
Response response = serviceDelegator.viewKeywords(ORCID);
assertNotNull(response);
Keywords keywords = (Keywords) response.getEntity();
assertNotNull(keywords);
assertNotNull(keywords.getLastModifiedDate());
assertNotNull(keywords.getLastModifiedDate().getValue());
assertEquals("/0000-0000-0000-0003/keywords", keywords.getPath());
assertEquals(1, keywords.getKeywords().size());
Keyword keyword = keywords.getKeywords().get(0);
assertNotNull(keyword);
assertNotNull(keyword.getLastModifiedDate());
assertNotNull(keyword.getLastModifiedDate().getValue());
assertEquals(Long.valueOf(9), keyword.getPutCode());
assertEquals("PUBLIC", keyword.getContent());
assertEquals(Visibility.PUBLIC.value(), keyword.getVisibility().value());
assertEquals("/0000-0000-0000-0003/keywords/9", keyword.getPath());
assertEquals("APP-5555555555555555", keyword.getSource().retrieveSourcePath());
}
use of org.orcid.jaxb.model.record_rc3.Keyword in project ORCID-Source by ORCID.
the class Utils method getKeyword.
public static Keyword getKeyword() {
Keyword keyword = new Keyword();
keyword.setContent("New keyword");
keyword.setVisibility(Visibility.LIMITED);
return keyword;
}
Aggregations