<commit_before>package be.cytomine.security

import grails.test.*

class UserTests extends GrailsUnitTestCase {
    protected void setUp() {
        super.setUp()
    }

    protected void tearDown() {
        super.tearDown()
    }

    void testSomething() {

    }

      void testAddUser() {
        mockDomain(User)
        def today = new Date()
        def user = new User(firstname:"John",lastname:"Doe",email:"<EMAIL>", dateCreated:today,password:"<PASSWORD>",username:"toto")

        assertEquals 'John', user.firstname
        assertEquals 'Doe', user.lastname
        assertEquals '<EMAIL>', user.email
    }


    void testValidEmail() {
        mockDomain(User)
        def today = new Date()
        def user = new User(firstname:"John",lastname:"Doe",email:"<EMAIL>", dateCreated:today,password:"<PASSWORD>",username:"toto")

        if(user.validate()) {
           println "ok"
        }
        else {
            println "nok"
            user.errors.allErrors.each {
            println it
            }
        }

        assertTrue 'validation should be OK', user.validate()
    }

    void testInValidEmail() {
        mockDomain(User)
        def today = new Date()
        def user = new User(firstname:"John",lastname:"Doe",email:"johndoe@", dateCreated:today,password:"<PASSWORD>",username:"toto")

        assertFalse 'validation should be NOK', user.validate()
    }
}
<commit_msg>CYTO-6<commit_after>package be.cytomine.security

import grails.test.*

class UserTests extends GrailsUnitTestCase {
    protected void setUp() {
        super.setUp()
    }

    protected void tearDown() {
        super.tearDown()
    }

    void testSomething() {

    }

      void testAddUser() {
        mockDomain(User)
        def today = new Date()
        def user = new User(firstname:"John",lastname:"Doe",email:"<EMAIL>", dateCreated:today,password:"<PASSWORD>",username:"toto")

        assertEquals 'John', user.firstname
        assertEquals 'Doe', user.lastname
        assertEquals '<EMAIL>', user.email
    }


    void testValidEmail() {
        mockDomain(User)
        def today = new Date()
        def user = new User(firstname:"John",lastname:"Doe",email:"<EMAIL>", dateCreated:today,password:"<PASSWORD>",username:"toto")

        /*if(user.validate()) {
           println "ok"
        }
        else {
            println "nok"
            user.errors.allErrors.each {
            println it
            }
        }    */

        assertTrue 'validation should be OK', user.validate()
    }

    void testInValidEmail() {
        mockDomain(User)
        def today = new Date()
        def user = new User(firstname:"John",lastname:"Doe",email:"johndoe@", dateCreated:today,password:"<PASSWORD>",username:"toto")

        assertFalse 'validation should be NOK', user.validate()
    }
}

{'fraction_non_alphanumeric': 0.13061946902654867, 'fraction_numerical': 0.00035398230088495576, 'mean_word_length': 2.437956204379562, 'pattern_counts': {'":': 0, '<': 15, '<?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': '6431979', 'n_tokens_mistral': 837, 'n_tokens_neox': 806, 'n_words': 168}