-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolving issue w/ enumerations not having metainformation, propogati…
…ng all of the metainformatin fixes, making sure that everything has the metainfo it should. This introduces a super super super subtle regression with certain error invariants, I'll fix those with another commit once some of the core descr infrastructure and understanding infra is all resolved.
- Loading branch information
Tom White
committed
Mar 12, 2013
1 parent
0b550e9
commit 0014034
Showing
8 changed files
with
268 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
simplTests/test/simpl/descriptions/beiber/FieldsAndClassesObtainAllMetaInformation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package simpl.descriptions.beiber; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import org.junit.Test; | ||
|
||
import ecologylab.serialization.primaryScenarioEnum; | ||
|
||
import simpl.annotations.dbal.simpl_filter; | ||
import simpl.annotations.dbal.simpl_inherit; | ||
import simpl.annotations.dbal.simpl_scalar; | ||
import simpl.annotations.dbal.simpl_tag; | ||
import simpl.descriptions.ClassDescriptor; | ||
import simpl.descriptions.ClassDescriptors; | ||
import simpl.descriptions.EnumerationDescriptor; | ||
import simpl.descriptions.FieldDescriptor; | ||
import simpl.descriptions.IMetaInformationProvider; | ||
import simpl.descriptions.MetaInformation; | ||
import simpl.exceptions.SIMPLDescriptionException; | ||
|
||
/** | ||
* The annotation parser is tested in the annotationParserTests... | ||
* this makes sure that the field, class, and enum descriptions all correctly use the annotaiton parser | ||
* and correclty capture relevant annotation information. :D | ||
* @author tom | ||
* | ||
*/ | ||
public class FieldsAndClassesObtainAllMetaInformation { | ||
|
||
|
||
@simpl_inherit | ||
@myRandomAnnotation | ||
class myAnnotatedClass | ||
{ | ||
@simpl_scalar | ||
@simpl_tag("another_tag_name") | ||
@myRandomAnnotation | ||
public Integer someField; | ||
} | ||
|
||
|
||
@Test | ||
public void testClassObtainsAllMetaInformation() { | ||
ClassDescriptor cd = ClassDescriptors.getClassDescriptor(myAnnotatedClass.class); | ||
|
||
assertFalse("Should not contain this metadata~", cd.containsMetaInformation("something_that_does_not_exist")); | ||
|
||
assertTrue("Should simpl_inherit!", cd.containsMetaInformation("simpl_inherit")); | ||
assertTrue("Should have myRandomAnnotation~",cd.containsMetaInformation("myRandomAnnotation")); | ||
|
||
MetaInformation simplInherit = cd.getMetaInformation("simpl_inherit"); | ||
assertEquals("simpl_inherit", simplInherit.getAnnotationName()); | ||
assertTrue("Should have no parameters!", simplInherit.getParameters().isEmpty()); | ||
|
||
MetaInformation myRandomAnnotation = cd.getMetaInformation("myRandomAnnotation"); | ||
assertEquals("myRandomAnnotation", myRandomAnnotation.getAnnotationName()); | ||
assertTrue("Should have no parameters!", myRandomAnnotation.getParameters().isEmpty()); | ||
|
||
|
||
FieldDescriptor fd = cd.allFieldDescriptors().get(0); | ||
assertTrue(fd.containsMetaInformation("simpl_scalar")); | ||
assertTrue(fd.containsMetaInformation("myRandomAnnotation")); | ||
|
||
assertTrue(fd.containsMetaInformation("simpl_tag")); | ||
|
||
MetaInformation simpl_tag = fd.getMetaInformation("simpl_tag"); | ||
assertTrue(simpl_tag.hasParameter("value")); | ||
assertEquals("another_tag_name", simpl_tag.getValueFor("value")); | ||
assertEquals("another_tag_name", simpl_tag.getValue()); | ||
} | ||
|
||
|
||
@Test | ||
public void testEnumerationDescriptionObtainsAllMetaInformation() throws SIMPLDescriptionException | ||
{ | ||
EnumerationDescriptor ed = EnumerationDescriptor.get(annotatedEnumeration.class); | ||
assertTrue(ed.containsMetaInformation("myRandomAnnotation")); | ||
assertTrue(ed.containsMetaInformation("simpl_tag")); | ||
assertEquals("my_spiffy_tag",ed.getMetaInformation("simpl_tag").getValue()); | ||
|
||
assertTrue(ed.getEnumerationEntries().get(0).containsMetaInformation("myRandomAnnotation")); | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
simplTests/test/simpl/descriptions/beiber/annotatedEnumeration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package simpl.descriptions.beiber; | ||
|
||
import simpl.annotations.dbal.simpl_scalar; | ||
import simpl.annotations.dbal.simpl_tag; | ||
|
||
@myRandomAnnotation | ||
@simpl_tag("my_spiffy_tag") | ||
public enum annotatedEnumeration { | ||
|
||
@myRandomAnnotation | ||
firstValue(3), | ||
secondValue(5), | ||
thirdValue(7); | ||
|
||
@simpl_scalar | ||
@myRandomAnnotation | ||
private Integer myValue; | ||
|
||
private annotatedEnumeration(Integer aValue) | ||
{ | ||
this.myValue = aValue; | ||
} | ||
} |
Oops, something went wrong.