Skip to content

Commit

Permalink
only use @transactional with sql and @lob without mongodb
Browse files Browse the repository at this point in the history
Fix #3010
  • Loading branch information
ruddell committed Feb 27, 2016
1 parent 6ce2695 commit 221bf5a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
Expand Up @@ -9,7 +9,7 @@
import java.util.HashSet;
import java.util.Set;<% } %>
import java.util.Objects;<% if (databaseType == 'cassandra') { %>
import java.util.UUID;<% } %><% if (fieldsContainBlob == true) { %>
import java.util.UUID;<% } %><% if (fieldsContainBlob == true && databaseType != 'mongodb') { %>
import javax.persistence.Lob;<% } %>
<% for (idx in fields) { if (fields[idx].fieldIsEnum == true) { %>
import <%=packageName%>.domain.enumeration.<%= fields[idx].fieldType %>;<% } } %>
Expand Down Expand Up @@ -52,7 +52,7 @@ public class <%= entityClass %>DTO implements Serializable {
@Size(min = <%= fieldValidateRulesMinbytes %>, max = <%= fieldValidateRulesMaxbytes %>)<% } %><% if (fieldValidateRules.indexOf('min') != -1) { %>
@Min(value = <%= fieldValidateRulesMin %>)<% } %><% if (fieldValidateRules.indexOf('max') != -1) { %>
@Max(value = <%= fieldValidateRulesMax %><%= (fieldValidateRulesMax > MAX_VALUE) ? 'L' : '' %>)<% } %><% if (fieldValidateRules.indexOf('pattern') != -1) { %>
@Pattern(regexp = "<%= fieldValidateRulesPatternJava %>")<% } } %><% if (fieldType == 'byte[]') { %>
@Pattern(regexp = "<%= fieldValidateRulesPatternJava %>")<% } } %><% if (fieldType == 'byte[]' && databaseType != 'mongodb') { %>
@Lob<% } %>
<%_ if (fieldTypeBlobContent != 'text') { _%>
private <%= fieldType %> <%= fieldName %>;
Expand Down
Expand Up @@ -24,8 +24,8 @@
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;

import javax.inject.Inject;
import javax.transaction.Transactional;
import javax.inject.Inject;<% if (databaseType == 'sql') { %>
import javax.transaction.Transactional;<% } %>
import java.util.*;

import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -143,8 +143,8 @@ public void testGetUnknownAccount() throws Exception {
.andExpect(status().isInternalServerError());
}

@Test
@Transactional
@Test<% if (databaseType == 'sql') { %>
@Transactional<% } %>
public void testRegisterValid() throws Exception {
UserDTO u = new UserDTO(
"joe", // login
Expand All @@ -167,8 +167,8 @@ public void testRegisterValid() throws Exception {
assertThat(user.isPresent()).isTrue();
}

@Test
@Transactional
@Test<% if (databaseType == 'sql') { %>
@Transactional<% } %>
public void testRegisterInvalidLogin() throws Exception {
UserDTO u = new UserDTO(
"funky-log!n", // login <-- invalid
Expand All @@ -191,8 +191,8 @@ public void testRegisterInvalidLogin() throws Exception {
assertThat(user.isPresent()).isFalse();
}

@Test
@Transactional
@Test<% if (databaseType == 'sql') { %>
@Transactional<% } %>
public void testRegisterInvalidEmail() throws Exception {
UserDTO u = new UserDTO(
"bob", // login
Expand All @@ -215,8 +215,8 @@ public void testRegisterInvalidEmail() throws Exception {
assertThat(user.isPresent()).isFalse();
}

@Test
@Transactional
@Test<% if (databaseType == 'sql') { %>
@Transactional<% } %>
public void testRegisterEmailEmpty() throws Exception {
UserDTO u = new UserDTO(
"bob", // login
Expand All @@ -239,8 +239,8 @@ public void testRegisterEmailEmpty() throws Exception {
assertThat(user.isPresent()).isFalse();
}

@Test
@Transactional
@Test<% if (databaseType == 'sql') { %>
@Transactional<% } %>
public void testRegisterDuplicateLogin() throws Exception {
// Good
UserDTO u = new UserDTO(
Expand Down Expand Up @@ -276,8 +276,8 @@ public void testRegisterDuplicateLogin() throws Exception {
assertThat(userDup.isPresent()).isFalse();
}

@Test
@Transactional
@Test<% if (databaseType == 'sql') { %>
@Transactional<% } %>
public void testRegisterDuplicateEmail() throws Exception {
// Good
UserDTO u = new UserDTO(
Expand Down Expand Up @@ -313,8 +313,8 @@ public void testRegisterDuplicateEmail() throws Exception {
assertThat(userDup.isPresent()).isFalse();
}

@Test
@Transactional
@Test<% if (databaseType == 'sql') { %>
@Transactional<% } %>
public void testRegisterAdminIsIgnored() throws Exception {
UserDTO u = new UserDTO(
"badguy", // login
Expand Down

0 comments on commit 221bf5a

Please sign in to comment.