package com.mvmlabs;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.mvmlabs.domain.User;
import com.mvmlabs.service.UserService;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
public class ApplicationTests {

    @Autowired
    UserService userService;
        
    @Test
    public void versionNullCausesAnExceptionOnUpdate() throws Exception {
        System.out.println("************* 0 - MVM *********** Have transaction");
        User user = new User();
        user.setUsername("Version Null");
        user.setNumberOfVisits(0);
        user.setVersion(null);
        user = userService.save(user);
        
        user = userService.registerVisit(user);
        
        Assert.assertEquals(new Integer(1), user.getNumberOfVisits());
        Assert.assertEquals(new Long(1), user.getVersion());
    }
    
    @Test
    public void versionZeroCausesExceptionOnUpdate() throws Exception {
        System.out.println("************* 1 - MVM *********** Have transaction");
        User user = new User();
        user.setUsername("Version Zero");
        user.setNumberOfVisits(0);
        user.setVersion(0L);
        user = userService.save(user);
        
        user = userService.registerVisit(user);
        
        Assert.assertEquals(new Integer(1), user.getNumberOfVisits());
        Assert.assertEquals(new Long(1), user.getVersion());
    }
    
    @Test
    public void versionOneDoesNotCausesExceptionOnUpdate() throws Exception {
        System.out.println("************* 2 - MVM *********** Have transaction");
        User user = new User();
        user.setUsername("Version One");
        user.setNumberOfVisits(0);
        user.setVersion(1L);
        user = userService.save(user);
        
        user = userService.registerVisit(user);
        
        Assert.assertEquals(new Integer(1), user.getNumberOfVisits());
        Assert.assertEquals(new Long(2), user.getVersion());
    }
    
    @Test
    public void versionOneDoesNotCausesExceptionWithMultipleUpdates() throws Exception {
        System.out.println("************* 3 - MVM *********** Have transaction");
        User user = new User();
        user.setUsername("Version One Multiple");
        user.setNumberOfVisits(0);
        user.setVersion(1L);
        user = userService.save(user);
        
        user = userService.registerVisit(user);
        user = userService.registerVisit(user);
        user = userService.registerVisit(user);
        
        Assert.assertEquals(new Integer(3), user.getNumberOfVisits());
        Assert.assertEquals(new Long(4), user.getVersion());
    }
    
}

@@ -649,90 +649,8 @@
 n %7B%0A
-        System.out.println(%22************* 0 - MVM *********** Have transaction%22);%0A
     
@@ -669,32 +669,32 @@
 r = new User();%0A
+
         user.set
@@ -1119,90 +1119,8 @@
 n %7B%0A
-        System.out.println(%22************* 1 - MVM *********** Have transaction%22);%0A
     
@@ -1593,90 +1593,8 @@
 n %7B%0A
-        System.out.println(%22************* 2 - MVM *********** Have transaction%22);%0A
     
@@ -1976,32 +1976,32 @@
 %0A    %0A    @Test%0A
+
     public void 
@@ -2077,90 +2077,8 @@
 n %7B%0A
-        System.out.println(%22************* 3 - MVM *********** Have transaction%22);%0A
     

Remove comments from test case