<commit_before>import { expect } from 'chai';
import {
  Route,
  Get,
  PathParam,
  QueryParam,
  RequestParam,
  GenericResponse,
  HttpResponseCode
} from '../../';
import { RequestHelper, ServerHelper } from '../helpers';

export class Student {
  _id: string;
  name: string;
  age: number;
  email: string;

  constructor(uuid?: string, name?: string, age?: number, email?: string) {
    this._id = uuid;
    this.name = name;
    this.age = age;
    this.email = email;
  }
}

const students: Student[] = [
  new Student('59d27001fc13ae439600012c', '<NAME>', 16, '<EMAIL>'),
  new Student('59d27001fc13ae439600012d', '<NAME>', 11, '<EMAIL>'),
  new Student('59d27001fc13ae439600012e', '<NAME>', 8, '<EMAIL>'),
  new Student('59d27001fc13ae439600012f', '<NAME>', 27, '<EMAIL>'),
  new Student('59d27001fc13ae4396000130', '<NAME>', 26, '<EMAIL>'),
  new Student('59d27001fc13ae4396000131', '<NAME>', 13, '<EMAIL>'),
  new Student('59d27001fc13ae4396000132', '<NAME>', 18, '<EMAIL>'),
  new Student('59d27001fc13ae4396000133', '<NAME>', 14, '<EMAIL>'),
  new Student('59d27001fc13ae4396000134', '<NAME>', 14, '<EMAIL>'),
  new Student('59d27001fc13ae4396000135', '<NAME>', 18, '<EMAIL>'),
  new Student('59d27001fc13ae4396000136', '<NAME>', 21, '<EMAIL>'),
  new Student('59d27001fc13ae4396000137', '<NAME>', 21, '<EMAIL>'),
  new Student('59d27001fc13ae4396000138', '<NAME>', 10, '<EMAIL>'),
  new Student('59d27001fc13ae4396000139', '<NAME>', 29, '<EMAIL>'),
  new Student('59d27001fc13ae439600013a', '<NAME>', 27, '<EMAIL>')
];

@Route('students')
export class StudentRS {
  @Get(':uuid')
  getStudent(@PathParam('uuid') uuid: string): Student {
    const student = students.find(st => st._id === uuid);
    return student;
  }

  @Get()
  getStudents(@QueryParam('name') name: string, @QueryParam('age') age: number): Student[] {
    return students;
  }
}

describe('HTTP Decorator tests', () => {
  before(async function() {
    this.timeout(0);
    await ServerHelper.initBasicServer();
  });

  it('Should GET a student', async () => {
    const result = await RequestHelper.get('/orche/students/59d27001fc13ae439600012c');
    const expectedValue = JSON.stringify({
      _id: '59d27001fc13ae439600012c',
      name: '<NAME>',
      age: 16,
      email: '<EMAIL>'
    });
    expect(result).to.be.equal(expectedValue);
  });
});<commit_msg>test(decorators): adding new test cases to the http decorators<commit_after>import { expect } from 'chai';
import {
  Route,
  All,
  NextParam,
  BodyParam,
  Post,
  Get,
  PathParam,
  QueryParam,
  RequestParam,
  HeaderParam,
  GenericResponse,
  HttpResponseCode
} from '../../';
import { RequestHelper, ServerHelper } from '../helpers';
import { NotNullValidator } from '@orchejs/validators';

export class Student {
  _id: string;
  name: string;
  age: number;
  email: string;

  constructor(uuid?: string, name?: string, age?: number, email?: string) {
    this._id = uuid;
    this.name = name;
    this.age = age;
    this.email = email;
  }
}

const students: Student[] = [
  new Student('59d27001fc13ae439600012c', '<NAME>', 16, '<EMAIL>'),
  new Student('59d27001fc13ae439600012d', '<NAME>', 11, '<EMAIL>'),
  new Student('59d27001fc13ae439600012e', '<NAME>', 8, '<EMAIL>'),
  new Student('59d27001fc13ae439600012f', '<NAME>', 27, '<EMAIL>'),
  new Student('59d27001fc13ae4396000130', '<NAME>', 26, '<EMAIL>'),
  new Student('59d27001fc13ae4396000131', '<NAME>', 13, '<EMAIL>'),
  new Student('59d27001fc13ae4396000132', '<NAME>', 18, '<EMAIL>'),
  new Student('59d27001fc13ae4396000133', '<NAME>', 14, '<EMAIL>'),
  new Student('59d27001fc13ae4396000134', '<NAME>', 14, '<EMAIL>'),
  new Student('59d27001fc13ae4396000135', '<NAME>', 18, '<EMAIL>'),
  new Student('59d27001fc13ae4396000136', '<NAME>', 21, '<EMAIL>'),
  new Student('59d27001fc13ae4396000137', '<NAME>', 21, '<EMAIL>'),
  new Student('59d27001fc13ae4396000138', '<NAME>', 10, '<EMAIL>'),
  new Student('59d27001fc13ae4396000139', '<NAME>', 29, '<EMAIL>'),
  new Student('59d27001fc13ae439600013a', '<NAME>', 27, '<EMAIL>')
];

@Route('students')
export class StudentRs {
  @All('/*')
  checkHeader(
    @HeaderParam('content-type') contentType: string, 
    @NextParam() next: any, 
    @RequestParam() req: any
  ) {
    if (!contentType) {
      req.headers['content-type'] = 'application/json';
    }
    next();
  }

  @Post()
  createStudent(@BodyParam({
    validators: [{ validator: NotNullValidator }]
  }) student: Student): Student {
    student._id = '59d27001fc13ae43960001123';
    students.push(student);
    return student;
  }

  @Get(':uuid')
  getStudent(@PathParam('uuid') uuid: string): Student {
    const student = students.find(st => st._id === uuid);
    return student;
  }

  @Get()
  getStudents(@QueryParam('name') name: string, @QueryParam('minAge') minAge: number): Student[] {
    const filteredStudents = students.filter(
      stu => stu.age >= minAge && stu.name.toLowerCase().indexOf(name.toLowerCase()) > -1
    );
    return filteredStudents;
  }
}

describe('HTTP Decorator tests', () => {
  before(async function() {
    this.timeout(0);
    await ServerHelper.initBasicServer();
  });

  it('Should POST a new student', async () => {
    const result = await RequestHelper.post('/orche/students', { name:'<NAME>' });
    expect(result.uuid).to.be.not.undefined;
  });

  it('Should GET a student', async () => {
    const result = await RequestHelper.get('/orche/students/59d27001fc13ae439600012c');
    expect(result.name).to.be.equal('<NAME>');
  });

  it('Should GET a list of students with name hu and  ', async () => {
    const result = await RequestHelper.get('/orche/students?name=hu&&minAge=18');
    expect(result).length.gte(2);
  });


});
{'fraction_non_alphanumeric': 0.18900523560209423, 'fraction_numerical': 0.12216404886561955, 'mean_word_length': 4.618627450980392, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 78, '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': '789665', 'n_tokens_mistral': 2459, 'n_tokens_neox': 2057, 'n_words': 427}