Skip to content

Commit

Permalink
fix sonar issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Feb 14, 2024
1 parent 10245b2 commit 8c10e5d
Showing 1 changed file with 52 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1070,15 +1070,12 @@ _%>

<%= primaryKey.type %> id = <%= persistInstance %>.get<%= primaryKey.nameCapitalized %>();

default<%= entityClass %>ShouldBeFound("<%= primaryKey.name %>.equals=" + id);
default<%= entityClass %>ShouldNotBeFound("<%= primaryKey.name %>.notEquals=" + id);
default<%= entityClass %>Filtering("<%= primaryKey.name %>.equals=" + id, "<%= primaryKey.name %>.notEquals=" + id);

<%_ if (primaryKey.typeLong || primaryKey.typeInteger) { _%>
default<%= entityClass %>ShouldBeFound("<%= primaryKey.name %>.greaterThanOrEqual=" + id);
default<%= entityClass %>ShouldNotBeFound("<%= primaryKey.name %>.greaterThan=" + id);
default<%= entityClass %>Filtering("<%= primaryKey.name %>.greaterThanOrEqual=" + id, "<%= primaryKey.name %>.greaterThan=" + id);

default<%= entityClass %>ShouldBeFound("<%= primaryKey.name %>.lessThanOrEqual=" + id);
default<%= entityClass %>ShouldNotBeFound("<%= primaryKey.name %>.lessThan=" + id);
default<%= entityClass %>Filtering("<%= primaryKey.name %>.lessThanOrEqual=" + id, "<%= primaryKey.name %>.lessThan=" + id);
<%_ } _%>
}

Expand All @@ -1090,23 +1087,23 @@ _%>
// Initialize the database
<%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>;

// Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> equals to <%= 'DEFAULT_' + searchBy.fieldNameUnderscored.toUpperCase() %>
default<%= entityClass %>ShouldBeFound("<%= searchBy.fieldName %>.equals=" + <%= 'DEFAULT_' + searchBy.fieldNameUnderscored.toUpperCase() %>);

// Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> equals to <%= 'UPDATED_' + searchBy.fieldNameUnderscored.toUpperCase() %>
default<%= entityClass %>ShouldNotBeFound("<%= searchBy.fieldName %>.equals=" + <%= 'UPDATED_' + searchBy.fieldNameUnderscored.toUpperCase() %>);
// Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> equals to
default<%= entityClass %>Filtering(
"<%= searchBy.fieldName %>.equals=" + <%= 'DEFAULT_' + searchBy.fieldNameUnderscored.toUpperCase() %>,
"<%= searchBy.fieldName %>.equals=" + <%= 'UPDATED_' + searchBy.fieldNameUnderscored.toUpperCase() %>
);
}

@Test<%= transactionalAnnotation %>
void getAll<%= entityClassPlural %>By<%= searchBy.fieldInJavaBeanMethod %>IsInShouldWork() <% if (!reactive) { %>throws Exception <% } %>{
// Initialize the database
<%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>;

// Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> in <%= 'DEFAULT_' + searchBy.fieldNameUnderscored.toUpperCase() %> or <%= 'UPDATED_' + searchBy.fieldNameUnderscored.toUpperCase() %>
default<%= entityClass %>ShouldBeFound("<%= searchBy.fieldName %>.in=" + <%= 'DEFAULT_' + searchBy.fieldNameUnderscored.toUpperCase() %> + "," + <%= 'UPDATED_' + searchBy.fieldNameUnderscored.toUpperCase() %>);

// Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> equals to <%= 'UPDATED_' + searchBy.fieldNameUnderscored.toUpperCase() %>
default<%= entityClass %>ShouldNotBeFound("<%= searchBy.fieldName %>.in=" + <%= 'UPDATED_' + searchBy.fieldNameUnderscored.toUpperCase() %>);
// Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> in
default<%= entityClass %>Filtering(
"<%= searchBy.fieldName %>.in=" + <%= 'DEFAULT_' + searchBy.fieldNameUnderscored.toUpperCase() %> + "," + <%= 'UPDATED_' + searchBy.fieldNameUnderscored.toUpperCase() %>,
"<%= searchBy.fieldName %>.in=" + <%= 'UPDATED_' + searchBy.fieldNameUnderscored.toUpperCase() %>
);
}

@Test<%= transactionalAnnotation %>
Expand All @@ -1115,10 +1112,10 @@ _%>
<%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>;

// Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> is not null
default<%= entityClass %>ShouldBeFound("<%= searchBy.fieldName %>.specified=true");

// Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> is null
default<%= entityClass %>ShouldNotBeFound("<%= searchBy.fieldName %>.specified=false");
default<%= entityClass %>Filtering(
"<%= searchBy.fieldName %>.specified=true",
"<%= searchBy.fieldName %>.specified=false"
);
}
<%_ } _%>
<%_ if (searchBy.fieldTypeString) { _%>
Expand All @@ -1127,23 +1124,23 @@ _%>
// Initialize the database
<%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>;

// Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> contains <%= 'DEFAULT_' + searchBy.fieldNameUnderscored.toUpperCase() %>
default<%= entityClass %>ShouldBeFound("<%= searchBy.fieldName %>.contains=" + <%= 'DEFAULT_' + searchBy.fieldNameUnderscored.toUpperCase() %>);

// Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> contains <%= 'UPDATED_' + searchBy.fieldNameUnderscored.toUpperCase() %>
default<%= entityClass %>ShouldNotBeFound("<%= searchBy.fieldName %>.contains=" + <%= 'UPDATED_' + searchBy.fieldNameUnderscored.toUpperCase() %>);
// Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> contains
default<%= entityClass %>Filtering(
"<%= searchBy.fieldName %>.contains=" + <%= 'DEFAULT_' + searchBy.fieldNameUnderscored.toUpperCase() %>,
"<%= searchBy.fieldName %>.contains=" + <%= 'UPDATED_' + searchBy.fieldNameUnderscored.toUpperCase() %>
);
}

@Test<%= transactionalAnnotation %>
void getAll<%= entityClassPlural %>By<%= searchBy.fieldInJavaBeanMethod %>NotContainsSomething() <% if (!reactive) { %>throws Exception <% } %>{
// Initialize the database
<%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>;

// Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> does not contain <%= 'DEFAULT_' + searchBy.fieldNameUnderscored.toUpperCase() %>
default<%= entityClass %>ShouldNotBeFound("<%= searchBy.fieldName %>.doesNotContain=" + <%= 'DEFAULT_' + searchBy.fieldNameUnderscored.toUpperCase() %>);

// Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> does not contain <%= 'UPDATED_' + searchBy.fieldNameUnderscored.toUpperCase() %>
default<%= entityClass %>ShouldBeFound("<%= searchBy.fieldName %>.doesNotContain=" + <%= 'UPDATED_' + searchBy.fieldNameUnderscored.toUpperCase() %>);
// Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> does not contain
default<%= entityClass %>Filtering(
"<%= searchBy.fieldName %>.doesNotContain=" + <%= 'UPDATED_' + searchBy.fieldNameUnderscored.toUpperCase() %>,
"<%= searchBy.fieldName %>.doesNotContain=" + <%= 'DEFAULT_' + searchBy.fieldNameUnderscored.toUpperCase() %>
);
}

<%_ }
Expand All @@ -1169,47 +1166,47 @@ _%>
// Initialize the database
<%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>;

// Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> is greater than or equal to <%= defaultValue %>
default<%= entityClass %>ShouldBeFound("<%= searchBy.fieldName %>.greaterThanOrEqual=" + <%= defaultValue %>);

// Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> is greater than or equal to <%= biggerValue %>
default<%= entityClass %>ShouldNotBeFound("<%= searchBy.fieldName %>.greaterThanOrEqual=" + <%= biggerValue %>);
// Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> is greater than or equal to
default<%= entityClass %>Filtering(
"<%= searchBy.fieldName %>.greaterThanOrEqual=" + <%= defaultValue %>,
"<%= searchBy.fieldName %>.greaterThanOrEqual=" + <%= biggerValue %>
);
}

@Test<%= transactionalAnnotation %>
void getAll<%= entityClassPlural %>By<%= searchBy.fieldInJavaBeanMethod %>IsLessThanOrEqualToSomething() <% if (!reactive) { %>throws Exception <% } %>{
// Initialize the database
<%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>;

// Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> is less than or equal to <%= defaultValue %>
default<%= entityClass %>ShouldBeFound("<%= searchBy.fieldName %>.lessThanOrEqual=" + <%= defaultValue %>);

// Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> is less than or equal to <%= smallerValue %>
default<%= entityClass %>ShouldNotBeFound("<%= searchBy.fieldName %>.lessThanOrEqual=" + <%= smallerValue %>);
// Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> is less than or equal to
default<%= entityClass %>Filtering(
"<%= searchBy.fieldName %>.lessThanOrEqual=" + <%= defaultValue %>,
"<%= searchBy.fieldName %>.lessThanOrEqual=" + <%= smallerValue %>
);
}

@Test<%= transactionalAnnotation %>
void getAll<%= entityClassPlural %>By<%= searchBy.fieldInJavaBeanMethod %>IsLessThanSomething() <% if (!reactive) { %>throws Exception <% } %>{
// Initialize the database
<%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>;

// Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> is less than <%= defaultValue %>
default<%= entityClass %>ShouldNotBeFound("<%= searchBy.fieldName %>.lessThan=" + <%= defaultValue %>);

// Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> is less than <%= biggerValue %>
default<%= entityClass %>ShouldBeFound("<%= searchBy.fieldName %>.lessThan=" + <%= biggerValue %>);
// Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> is less than
default<%= entityClass %>Filtering(
"<%= searchBy.fieldName %>.lessThan=" + <%= biggerValue %>,
"<%= searchBy.fieldName %>.lessThan=" + <%= defaultValue %>
);
}

@Test<%= transactionalAnnotation %>
void getAll<%= entityClassPlural %>By<%= searchBy.fieldInJavaBeanMethod %>IsGreaterThanSomething() <% if (!reactive) { %>throws Exception <% } %>{
// Initialize the database
<%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>;

// Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> is greater than <%= defaultValue %>
default<%= entityClass %>ShouldNotBeFound("<%= searchBy.fieldName %>.greaterThan=" + <%= defaultValue %>);

// Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> is greater than <%= smallerValue %>
default<%= entityClass %>ShouldBeFound("<%= searchBy.fieldName %>.greaterThan=" + <%= smallerValue %>);
// Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> is greater than
default<%= entityClass %>Filtering(
"<%= searchBy.fieldName %>.greaterThan=" + <%= smallerValue %>,
"<%= searchBy.fieldName %>.greaterThan=" + <%= defaultValue %>
);
}

<%_ } _%>
Expand Down Expand Up @@ -1271,6 +1268,11 @@ _%>
}

<%_ }); _%>
private void default<%= entityClass %>Filtering(String shouldBeFound, String shouldNotBeFound) throws Exception {
default<%= entityClass %>ShouldBeFound(shouldBeFound);
default<%= entityClass %>ShouldNotBeFound(shouldNotBeFound);
}

/**
* Executes the search, and checks that the default entity is returned.
*/
Expand Down

0 comments on commit 8c10e5d

Please sign in to comment.