/*
 * Copyright 2017, TeamDev Ltd. All rights reserved.
 *
 * Redistribution and use in source and/or binary forms, with or without
 * modification, must retain the above copyright notice and the following
 * disclaimer.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package org.spine3.server.entity;

import org.spine3.test.entity.Project;
import org.spine3.testdata.Sample;

import static org.spine3.base.Identifiers.newUuid;

/**
 * Extracted from {@link EntityShould}
 *
 * @author Mikhail Mikhaylov
 */
class TestEntity extends Entity<String, Project> {

    private boolean isValidateMethodCalled = false;

    static TestEntity newInstance(String id) {
        final TestEntity result = org.spine3.test.Given.entityOfClass(TestEntity.class)
                                                       .withId(id)
                                                       .build();
        return result;
    }

    static TestEntity withState() {
        final TestEntity result = org.spine3.test.Given.entityOfClass(TestEntity.class)
                                                       .withId(newUuid())
                                                       .withState(Sample.messageOfType(Project.class))
                                                       .withVersion(3)
                                                       .build();
        return result;
    }

    static TestEntity withState(TestEntity entity) {
        final TestEntity result = org.spine3.test.Given.entityOfClass(TestEntity.class)
                                                       .withId(entity.getId())
                                                       .withState(entity.getState())
                                                       .withVersion(entity.getVersion())
                                                       .build();
        return result;
    }

    private TestEntity(String id) {
        super(id);
    }

    @Override
    protected void validate(Project state) throws IllegalStateException {
        super.validate(state);
        isValidateMethodCalled = true;
    }

    boolean isValidateMethodCalled() {
        return isValidateMethodCalled;
    }
}

@@ -1045,16 +1045,46 @@
 ntity;%0A%0A
+import org.spine3.test.Given;%0A
 import o
@@ -1467,32 +1467,16 @@
 esult = 
-org.spine3.test.
 Given.en
@@ -1505,32 +1505,16 @@
 .class)%0A
-                
         
@@ -1595,32 +1595,16 @@
         
-                
 .build()
@@ -1705,32 +1705,16 @@
 esult = 
-org.spine3.test.
 Given.en
@@ -2173,32 +2173,16 @@
 esult = 
-org.spine3.test.
 Given.en

Remove redundant FQNs.