Question: There's a way to handle this validation ?

```
class java.lang.Integer cannot be cast to class java.lang.String

```

Code:

```
private List<Map<String,String>> getEmpRegistry(
        List<Map<String,String>> tblObjRowsList,
        Integer rowNumber
){
    List<Map<String,String>> empRegistry = new ArrayList<>();
    for (Map<String,String> empR : tblObjRowsList){
        if (empR.get("id").equals(rowNumber)){
            empRegistry.add(empR);
        }
    }
    return empRegistry;
}

```

Looks wrong, because I can't compare String and Integer.

But for some reason `tblObjRowsList` is extracted from stored procedure in MySQL via Spring Data:

```
@Query(value="CALL SP_ObjsRowDetails2(:Id,:templateId,:strMode)",nativeQuery = true)
List<Map<String,String>> getRowDetail  (@PathParam("Id") Integer id,
                                        @PathParam("templateId") Integer templateId,
                                        @PathParam("strMode") Integer strMode);

```

Extract the data like this:

[![enter image description here](https://i.stack.imgur.com/X0Etz.png)](https://i.stack.imgur.com/X0Etz.png)

I tried:

```
Integer.parseInt(empR.get("id")).equals(rowNumber)

Integer.parseInt(empR.get("id").toString()).equals(rowNumber)

empR.get("id").toString().equals(String.valueOf(rowNumber))

```

And the most interesting thing is:

[![enter image description here](https://i.stack.imgur.com/4R0es.png)](https://i.stack.imgur.com/4R0es.png)

Doesn't make sense, if the source variable is `Map<String,String>`

Answer: 
Although you may be able to find a solution on your own by "Alt + Clicking" on every variable until to come up with the right type structure, better use this snippet:

The following works on Typescript, if you want to use it on javascript just switch to using "require()" imports as well as getting rid of the types:

```
    import {Wallet, Contract} from "ethers";
    import {MockProvider} from "ethereum-waffle";
    import {ethers, waffle} from "hardhat";
    const {loadFixture, deployContract} = waffle;

//Contract ABI
// For typescript only!
// In order to be able to import .json files make sure you tsconfig.json has set "compilerOptions" > "resolveJsonModule": true. My tsconfig.json at the bottom!
//For obvious reasons change this to the path of your compiled ABI

  import * as TodoListABI from "../artifacts/contracts/TodoList.sol/TodoList.json";

    //Fixtures
  async function fixture(_wallets: Wallet[], _mockProvider: MockProvider) {
    const signers = await ethers.getSigners();
    let token: Contract = await deployContract(signers[0], TodoListABI);
    return {token};
  }

```

And then, within your mocha-chai tests

```
it("My unit test", async function () {
    const {token} = await loadFixture(fixture);
    // Your code....
  });

```

My tsconfig.json for this hardhat project

```
{
  "compilerOptions": {
    "target": "es2018",
    "module": "commonjs",
    "strict": true,
    "esModuleInterop": true,
    "outDir": "dist",
    "resolveJsonModule": true
  },
  "include": ["./scripts", "./test"],
  "files": ["./hardhat.config.ts"]
}

```
Remember, hardhat uses mocha as its test runner, so you can use the hooks that mocha describes in its documentation: before(), after(), beforeEach(), and afterEach().

Here's an example of deploying a token contract and using the contract instance to run tests.

```js
beforeEach(async function () {

  Token = await ethers.getContractFactory("Token");
  [owner, addr1, addr2, ...addrs] = await ethers.getSigners();

  hardhatToken = await Token.deploy();
});

describe("Deployment", function () {

  it("Should set the right owner", async function () {
    expect(await hardhatToken.owner()).to.equal(owner.address);
  });

});
```