/*
* Copyright 2011, Mysema Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mysema.query.codegen;
import static org.junit.Assert.assertEquals;
import java.util.Collections;
import org.junit.Test;
import com.mysema.codegen.model.SimpleType;
import com.mysema.codegen.model.Type;
import com.mysema.codegen.model.TypeCategory;
public class PropertyTest {
@Test
public void Equals_And_HashCode() {
Type typeModel = new SimpleType(TypeCategory.ENTITY, "com.mysema.query.DomainClass", "com.mysema.query", "DomainClass", false,false);
EntityType type = new EntityType(typeModel);
Property p1 = new Property(type, "property", type, Collections.<String>emptyList());
Property p2 = new Property(type, "property", type, Collections.<String>emptyList());
assertEquals(p1, p1);
assertEquals(p1, p2);
assertEquals(p1.hashCode(), p2.hashCode());
}
@Test
public void EscapedName() {
Type typeModel = new SimpleType(TypeCategory.ENTITY, "com.mysema.query.DomainClass", "com.mysema.query", "DomainClass", false,false);
EntityType type = new EntityType(typeModel);
Property property = new Property(type, "boolean", type, Collections.<String>emptyList());
assertEquals("boolean$", property.getEscapedName());
}
}