Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

annotation_experimental_enum #200

Closed
wants to merge 1 commit into from

Conversation

asmab89
Copy link
Contributor

@asmab89 asmab89 commented Oct 1, 2020

In this branch, I solved the annotation @experimental on enum class. I just test the result on ProblemType enum class, however, we can easily generalize to other enum classes.

…I just test the result on ProblemType enum class
@asmab89 asmab89 requested a review from arcuri82 October 1, 2020 18:22
Copy link
Collaborator

@arcuri82 arcuri82 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! thanks for this first PR ;) There was a bit of misunderstanding... but that's OK ;) let me know if my comment are unclear. we can also discuss them in person (i ll be in the office tomorrow, at least in the afternoon)

@@ -126,13 +126,16 @@ class EMConfig {
}
return description
}
// This is just an example for Problem Type but
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code should not be specific for problemType, but generic

}

fun getDescription(m: KMutableProperty<*>): ConfigDescription {

val cfg = (m.annotations.find { it is Cfg } as? Cfg)
?: throw IllegalArgumentException("Property ${m.name} is not annotated with @Cfg")

// println(cfg.description)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove all these occurrences of commented out println statements


@Experimental
@Cfg("The type of SUT we want to generate tests for, e.g., a RESTful API")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove @Experimental. the option problemType is not experimental, just the choice WEB is, for now

@@ -21,12 +21,13 @@ object ConfigToMarkdown {
fun toMarkdown(): String {

val buffer = StringBuilder()

//
defaultInstance.addAnnotationsEnumExperiment()
addHeader(buffer)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

@@ -103,6 +106,10 @@ object ConfigToMarkdown {

val sorted = experimental.sortedBy { it.name }

//for (element in sorted)
// println(element.name)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove those commented out code

@@ -180,8 +190,30 @@ object ConfigToMarkdown {
buffer.append(" *Constraints*: `${description.constraints}`.")
}
if(description.enumValues.isNotBlank()){
buffer.append(" *Valid values*: `${description.enumValues}`.")
var experimentalValues = ""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here enumValues is a string. likely we will need 2 separated strings, one for regular enum values, and another one for experimetal enum values (if any)

{

buffer.append(" *Valid values*: `${description.enumValues}`, *Experimental Values*: `This is under work` ")
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there is no experimental value, then the *Experimental values* label should not be printed (also notice lower case for v)

@@ -172,10 +175,12 @@ class EMConfig {
val returnType = m.returnType.javaType as Class<*>

if (returnType.isEnum) {

val elements = returnType.getDeclaredMethod("values")
.invoke(null) as Array<*>

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is where you will need reflection to read annotations, and see if any value is marked with @Experimental.
likely will need another variable besides enumValues to keep track of any found experimental enum

@asmab89 asmab89 closed this Oct 3, 2020
@asmab89 asmab89 deleted the annotation_experimental_enum_issue branch October 3, 2020 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants