-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* setup sort, count, and fix criteria grouping * setup jacoco * setup badges * commit badges * add some unit tests --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
80c626c
commit 0146965
Showing
22 changed files
with
512 additions
and
152 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created | ||
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path | ||
|
||
name: Maven Package | ||
|
||
on: [ push, pull_request ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
packages: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
- name: Build with Maven | ||
run: mvn -B verify --file pom.xml | ||
|
||
# generates coverage-report.md and publishes as checkrun | ||
- name: Generate JaCoCo Badge | ||
uses: cicirello/jacoco-badge-generator@v2 | ||
with: | ||
jacoco-csv-file: java-odoo-rpc-core/target/site/jacoco/jacoco.csv | ||
badges-directory: .github/badges | ||
generate-coverage-badge: true | ||
coverage-badge-filename: rpc-core-jacoco.svg | ||
coverage-label: rpc-core | ||
colors: '#4c1 #97ca00 #a4a61d #dfb317 #fe7d37 #e05d44' | ||
intervals: 100 80 70 60 50 0 | ||
|
||
# generates coverage-report.md and publishes as checkrun | ||
- name: Generate JaCoCo Badge | ||
uses: cicirello/jacoco-badge-generator@v2 | ||
with: | ||
jacoco-csv-file: java-odoo-json-rpc-client/target/site/jacoco/jacoco.csv | ||
badges-directory: .github/badges | ||
generate-coverage-badge: true | ||
coverage-badge-filename: json-rpc-client-jacoco.svg | ||
coverage-label: json-rpc | ||
colors: '#4c1 #97ca00 #a4a61d #dfb317 #fe7d37 #e05d44' | ||
intervals: 100 80 70 60 50 0 | ||
|
||
# generates coverage-report.md and publishes as checkrun | ||
- name: Generate JaCoCo Badge | ||
uses: cicirello/jacoco-badge-generator@v2 | ||
with: | ||
jacoco-csv-file: java-odoo-xml-rpc-core/target/site/jacoco/jacoco.csv | ||
badges-directory: .github/badges | ||
generate-coverage-badge: true | ||
coverage-badge-filename: xml-rpc-core-jacoco.svg | ||
coverage-label: xml-rpc | ||
colors: '#4c1 #97ca00 #a4a61d #dfb317 #fe7d37 #e05d44' | ||
intervals: 100 80 70 60 50 0 | ||
|
||
- name: Commit and push the badge (if it changed) | ||
uses: EndBug/add-and-commit@v9 | ||
with: | ||
default_author: github_actions | ||
message: 'commit badges' | ||
add: '*.svg' | ||
author: "GitHub Actions" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
java-odoo-rpc-core/src/main/java/ch/helvethink/odoo4java/tools/CriteriaTools.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2024 Helvethink | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
* | ||
*/ | ||
|
||
package ch.helvethink.odoo4java.tools; | ||
|
||
import ch.helvethink.odoo4java.FetchException; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Tooling class for criteria | ||
*/ | ||
public final class CriteriaTools { | ||
|
||
/** | ||
* Hide constructor because this is a tooling class | ||
*/ | ||
private CriteriaTools(){} | ||
|
||
/** | ||
* Group varargs by 3 for requests | ||
* @param requestCriteria List of objects for request | ||
* @return criteria grouped | ||
*/ | ||
public static List<List<List<Object>>> groupCriteria(final Object[] requestCriteria) { | ||
checkCriteriaArraySize(requestCriteria); | ||
final List<List<Object>> criteria = new ArrayList<>(); | ||
for(int i = 0; i < requestCriteria.length; i = i+3) { | ||
criteria.add(List.of(requestCriteria[i],requestCriteria[i+1],requestCriteria[i+2])); | ||
} | ||
return List.of(criteria); | ||
} | ||
|
||
/** | ||
* Check if array is well constructed | ||
* @param requestCriteria The request criteria array | ||
*/ | ||
private static void checkCriteriaArraySize(final Object[] requestCriteria) { | ||
if(requestCriteria.length % 3 != 0) { | ||
throw new FetchException("Criteria must be an array of size dividable by 3 (term1, operator, term2) for each criteria"); | ||
} | ||
} | ||
|
||
/** | ||
* Group varargs by 3 for requests | ||
* @param requestCriteria List of strings for request | ||
* @return criteria grouped | ||
*/ | ||
public static List<List<List<String>>> groupCriteria(final String[] requestCriteria) { | ||
if(requestCriteria.length % 3 != 0) { | ||
|
||
} | ||
final List<List<String>> criteria = new ArrayList<>(); | ||
for(int i = 0; i < requestCriteria.length; i = i+3) { | ||
criteria.add(List.of(requestCriteria[i],requestCriteria[i+1],requestCriteria[i+2])); | ||
} | ||
return List.of(criteria); | ||
} | ||
|
||
} |
Oops, something went wrong.