<commit_before>package se.su.it.svc.aspect

import org.aopalliance.intercept.MethodInvocation
import spock.lang.Specification

import java.lang.reflect.Method

class SanitizeWebParametersAspectSpec extends Specification {
  def setup() {}
  def cleanup() {}

  def "invoke: Test method invocation override."() {
    given:
    Object[] args = ["foo ", "kaka", new Object()]

    SanitizeWebParametersAspect wspa = GroovySpy(SanitizeWebParametersAspect)
    MethodInvocation methodInvocation = GroovyMock(MethodInvocation) {
      1 * getMethod(*_) >> {
        return GroovyMock(Method) {
          getName() >> "superiorMethod"
        }
      }
      1 * getArguments(*_) >> {
        return args
      }
    }
    when:
    def resp = wspa.invoke(methodInvocation)

    then:
    resp == null
  }

  def "washArgs: Test that Strings are properly trimmed and washed."() {<commit_msg>Fixed broken test<commit_after>package se.su.it.svc.aspect

import org.aopalliance.intercept.MethodInvocation
import spock.lang.Specification

class SanitizeWebParametersAspectSpec extends Specification {
  def setup() {}
  def cleanup() {}

  private class DummyClass {
    public String foobar(String foo) {
      return foo
    }
  }

  def "invoke: Test method invocation override."() {
    given:
    Object[] args = ["foo"]
    def caller  = new DummyClass()

    SanitizeWebParametersAspect wspa = GroovySpy(SanitizeWebParametersAspect)
    MethodInvocation methodInvocation = GroovyMock(MethodInvocation) {
      1* getMethod() >> {
        return caller.class.getMethod("foobar", String)
      }
      1 * getArguments() >> {
        return args
      }
      1 * getThis() >> {
        return caller
      }
    }
    when:
    def resp = wspa.invoke(methodInvocation)

    then:
    resp == 'foo'
  }

  def "washArgs: Test that Strings are properly trimmed and washed."() {
{'fraction_non_alphanumeric': 0.10374331550802139, 'fraction_numerical': 0.00267379679144385, 'mean_word_length': 3.015021459227468, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2771836', 'n_tokens_mistral': 577, 'n_tokens_neox': 560, 'n_words': 137}