#vulnerable code 
                                public void testSaveRetrieve() {
        String randomApiString = this.getRandomString();

        this.api.saveApi(new ApiResult(0, randomApiString, "privateKey", "", ""));
        ApiResult apiResult = this.api.getApiByPublicKey(randomApiString);

        assertThat(apiResult.getPublicKey()).isEqualTo(randomApiString);
        assertThat(apiResult.getPrivateKey()).isEqualTo("privateKey");

        this.api.deleteApiByPublicKey(randomApiString);
    } 
                            #location 7 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                                public void testSaveRetrieve() {
        String randomApiString = this.getRandomString();

        this.api.saveApi(new ApiResult(0, randomApiString, "privateKey", "", ""));
        Optional<ApiResult> apiByPublicKey = this.api.getApiByPublicKey(randomApiString);

        assertThat(apiByPublicKey.get().getPublicKey()).isEqualTo(randomApiString);
        assertThat(apiByPublicKey.get().getPrivateKey()).isEqualTo("privateKey");

        this.api.deleteApiByPublicKey(randomApiString);
    }