0

Currently, I am using RestAssured for API automation in my project. As we know, it is a Java Project.

When I look at the code of class named "TestSpecificationImpl" in Rest-Assured API. I can see that, it is using methods like:

def Response put(URL url) {
    put(notNull(url, "URL").toString())
  }

  def Response delete(URL url) {
    delete(notNull(url, "URL").toString())
  }

I heard about the concept of local variable type inference in java. But it is a concept of Java 10 and I am using java 8.

while googling, I find that "def" is used in python and groovy language. But, I am using java.

So, how come it is possible to use keywords like "def" in java class? Is it possible to use other programming languages keywords in java?

Please let me know in comment section, if you need any information from my end. Any help would be appreciated.

Screenshot of methods with "def" keyword:

Screenshot

You can find the complete code of java class at below URL:

TestSpecificationImpl.class

Pramod Kajla
  • 113
  • 1
  • 10

1 Answers1

1

The file you referenced is a .groovy file. You appear to have a file from the groovy RestAssured API. Try checking the version you downloaded from the RestAssured website :)

Catogram
  • 303
  • 1
  • 12
  • Compiled Groovy file is also saved with .class extension (same as Java class). That's why I got confused. REST Assured is implemented in Groovy and uses the builder pattern to create requests, set headers, parse the response and then match them with expected data. – Pramod Kajla Jan 14 '21 at 10:49
  • Ah cool. Sounds like you know more than me :) – Catogram Jan 14 '21 at 23:43