-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also interpret cost JSON object in case it is returned by oak search
engine #730
- Loading branch information
Showing
2 changed files
with
51 additions
and
7 deletions.
There are no files selected for viewing
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
35 changes: 35 additions & 0 deletions
35
...ntroltool-bundle/src/test/java/biz/netcentric/cq/tools/actool/helper/QueryHelperTest.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,35 @@ | ||
/* | ||
* (C) Copyright 2023 Cognizant Netcentric. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package biz.netcentric.cq.tools.actool.helper; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.io.IOException; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
|
||
public class QueryHelperTest { | ||
|
||
@Test | ||
public void testGetCostFromJsonScalar() throws JsonProcessingException, IOException { | ||
|
||
assertEquals(189540, QueryHelper.getCostFromJsonStr("{ \"s\": 189540.0 }")); | ||
} | ||
|
||
@Test | ||
public void testGetCostFromJsonObject() throws JsonProcessingException, IOException { | ||
|
||
// the keys in sub object happen to be unquoted, the impl needs to use JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES | ||
assertEquals(1, QueryHelper.getCostFromJsonStr("{ \"s\": { perEntry: 1.0, perExecution: 1.0, count: 47814 } }")); | ||
|
||
} | ||
|
||
} |