List of usage examples for org.apache.commons.collections CollectionUtils get
public static Object get(Object object, int index)
index
-th value in object
, throwing IndexOutOfBoundsException
if there is no such element or IllegalArgumentException
if object
is not an instance of one of the supported types. From source file:hr.fer.zemris.vhdllab.entity.FileTest.java
@Before public void initEntity() throws Exception { Project project = new ProjectStub(); entity = (File) CollectionUtils.get(project.getFiles(), 0); }
From source file:com.nesscomputing.service.discovery.client.internal.TestConsistentRingGroup.java
@Test public void testBasic() { ConsistentHashRing ring = group.getRing("type1"); Assert.assertEquals(1, ring.size()); ServiceInformation service = (ServiceInformation) CollectionUtils.get(ring, 0); Assert.assertEquals("type1", service.getServiceType()); }
From source file:hr.fer.zemris.vhdllab.dao.impl.PredefinedFileDaoImplTest.java
@Test public void getPredefinedFiles() { Set<File> files = dao.getPredefinedFiles(); assertNotNull(files);// w ww. j a v a 2 s. c o m assertEquals(2, files.size()); File file = (File) CollectionUtils.get(files, 0); assertNull(file.getId()); assertNull(file.getVersion()); assertNull(file.getProject()); assertEquals(FileType.PREDEFINED, file.getType()); assertTrue(file.getName().startsWith("PREDEFINED_FILE")); assertNotNull(file.getData()); // Files are defensively copied before return! file.setName("new predefined name"); assertFalse(files.equals(dao.getPredefinedFiles())); }
From source file:com.nesscomputing.service.discovery.client.internal.TestConsistentRingGroup.java
@Test public void testFallback() { ConsistentHashRing ring = group.getRing("type3"); Assert.assertEquals(1, ring.size()); ServiceInformation service = (ServiceInformation) CollectionUtils.get(ring, 0); Assert.assertEquals(null, service.getServiceType()); }
From source file:hr.fer.zemris.vhdllab.entity.FileHistoryTest.java
@Test public void constructorFileHistory() throws Exception { History history = new HistoryStub(); File file = (File) CollectionUtils.get(new ProjectStub().getFiles(), 0); FileHistory another = new FileHistory(file, history); assertEquals("name not same.", file.getName(), another.getName()); assertEquals("project id not same.", file.getProject().getId(), another.getProjectId()); assertEquals("history not same.", history, another.getHistory()); }
From source file:gov.nih.nci.caintegrator.domain.annotation.NumericAnnotationValueTest.java
/** * Tests conversion from a numeric value back to a different numeric value. * * @throws ValidationException on unexpected error *//*from w ww .j av a 2 s . c om*/ @Test public void numericToDifferentNumeric() throws ValidationException { AnnotationDefinition annotationDefinition = new AnnotationDefinition(); annotationDefinition.setDataType(AnnotationTypeEnum.NUMERIC); annotationDefinition.getAnnotationValueCollection().add(annotationValue); AnnotationDefinition otherDefinition = new AnnotationDefinition(); otherDefinition.setDataType(AnnotationTypeEnum.NUMERIC); otherDefinition.getAnnotationValueCollection().add(annotationValue); annotationValue.setAnnotationDefinition(annotationDefinition); annotationValue.convertAnnotationValue(otherDefinition); assertTrue(annotationDefinition.getAnnotationValueCollection().isEmpty()); assertEquals(2, otherDefinition.getAnnotationValueCollection().size()); NumericAnnotationValue value = (NumericAnnotationValue) CollectionUtils .get(otherDefinition.getAnnotationValueCollection(), 1); assertEquals(1, value.getNumericValue(), 0); assertNotSame(annotationValue, value); }
From source file:gov.nih.nci.caintegrator.domain.annotation.StringAnnotationValueTest.java
/** * Tests conversion from a string value back to a different string value. * * @throws ValidationException on unexpected error *///from w ww. ja va2 s . c om @Test public void stringToDifferentString() throws ValidationException { AnnotationDefinition annotationDefinition = new AnnotationDefinition(); annotationDefinition.setDataType(AnnotationTypeEnum.STRING); annotationDefinition.getAnnotationValueCollection().add(annotationValue); AnnotationDefinition otherDefinition = new AnnotationDefinition(); otherDefinition.setDataType(AnnotationTypeEnum.STRING); otherDefinition.getAnnotationValueCollection().add(annotationValue); annotationValue.setAnnotationDefinition(annotationDefinition); annotationValue.convertAnnotationValue(otherDefinition); assertTrue(annotationDefinition.getAnnotationValueCollection().isEmpty()); assertEquals(2, otherDefinition.getAnnotationValueCollection().size()); StringAnnotationValue value = (StringAnnotationValue) CollectionUtils .get(otherDefinition.getAnnotationValueCollection(), 1); assertEquals(STRING_VALUE, value.getStringValue()); assertNotSame(annotationValue, value); }
From source file:gov.nih.nci.caintegrator.domain.annotation.DateAnnotationValueTest.java
/** * Tests conversion from a date value back to a different date value. * * @throws ValidationException on unexpected error *//*from w ww . j a v a2 s . com*/ @Test public void dateToDifferentDate() throws ValidationException { AnnotationDefinition annotationDefinition = new AnnotationDefinition(); annotationDefinition.setDataType(AnnotationTypeEnum.DATE); annotationDefinition.getAnnotationValueCollection().add(annotationValue); AnnotationDefinition otherDefinition = new AnnotationDefinition(); otherDefinition.setDataType(AnnotationTypeEnum.DATE); otherDefinition.getAnnotationValueCollection().add(annotationValue); annotationValue.setAnnotationDefinition(annotationDefinition); annotationValue.convertAnnotationValue(otherDefinition); assertTrue(annotationDefinition.getAnnotationValueCollection().isEmpty()); assertEquals(2, otherDefinition.getAnnotationValueCollection().size()); DateAnnotationValue value = (DateAnnotationValue) CollectionUtils .get(otherDefinition.getAnnotationValueCollection(), 1); assertEquals(firstDayOf2001, value.getDateValue()); assertNotSame(annotationValue, value); }
From source file:curam.molsa.test.customfunctions.MOLSADOMReader.java
/** * Get DOM Node from query./*from w w w . j a v a2 s .com*/ * * @param startElement * @param query * @return CollectionUtils */ public static Node node(final Object startElement, final String query) { final List<Node> nodeList = nodes(startElement, query); if (nodeList.isEmpty()) { return null; } return (Node) CollectionUtils.get(nodeList, 0); }
From source file:hr.fer.zemris.vhdllab.service.workspace.ProjectMetadataTest.java
@Test public void constructorHierarchyFiles() { metadata = new ProjectMetadata(hierarchy, files); assertEquals(hierarchy, metadata.getHierarchy()); assertEquals(2, metadata.getFiles().size()); files.add(new File()); assertEquals(2, metadata.getFiles().size()); File file = (File) CollectionUtils.get(metadata.getFiles(), 0); assertNull(file.getProject());/* w w w. ja va2s . c o m*/ file = (File) CollectionUtils.get(files, 0); file.setName("new_name"); File another = (File) CollectionUtils.get(metadata.getFiles(), 0); assertFalse(file.equals(another)); }