-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FSTORE-1139] Get feature store requests can throw NullPointerExcepti…
…on is the project is not properly initialized (#1646)
- Loading branch information
Showing
2 changed files
with
73 additions
and
6 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
66 changes: 66 additions & 0 deletions
66
...rks-common/src/test/io/hops/hopsworks/common/featurestore/TestFeaturestoreController.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,66 @@ | ||
/* | ||
* This file is part of Hopsworks | ||
* Copyright (C) 2023, Hopsworks AB. All rights reserved | ||
* | ||
* Hopsworks is free software: you can redistribute it and/or modify it under the terms of | ||
* the GNU Affero General Public License as published by the Free Software Foundation, | ||
* either version 3 of the License, or (at your option) any later version. | ||
* | ||
* Hopsworks is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | ||
* PURPOSE. See the GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License along with this program. | ||
* If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package io.hops.hopsworks.common.featurestore; | ||
|
||
import io.hops.hopsworks.persistence.entity.dataset.Dataset; | ||
import io.hops.hopsworks.persistence.entity.dataset.DatasetType; | ||
import io.hops.hopsworks.persistence.entity.featurestore.Featurestore; | ||
import io.hops.hopsworks.persistence.entity.project.Project; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class TestFeaturestoreController { | ||
|
||
@Test | ||
public void testGetProjectFeaturestores() { | ||
FeaturestoreController featurestoreController = new FeaturestoreController(); | ||
Featurestore featurestore = new Featurestore(); | ||
featurestore.setId(1); | ||
|
||
Dataset fsDataset = new Dataset(); | ||
fsDataset.setDsType(DatasetType.FEATURESTORE); | ||
fsDataset.setFeatureStore(featurestore); | ||
|
||
Project project = new Project(); | ||
project.setDatasetCollection(Arrays.asList(fsDataset)); | ||
project.setDatasetSharedWithCollection(new ArrayList<>()); | ||
|
||
List<Featurestore> projectFeaturestores = featurestoreController.getProjectFeaturestores(project); | ||
Assert.assertEquals(featurestore.getId(), projectFeaturestores.get(0).getId()); | ||
} | ||
|
||
@Test | ||
public void testGetProjectFeaturestores_notInitialized() { | ||
FeaturestoreController featurestoreController = new FeaturestoreController(); | ||
|
||
Dataset fsDataset = new Dataset(); | ||
fsDataset.setDsType(DatasetType.FEATURESTORE); | ||
fsDataset.setFeatureStore(null); | ||
|
||
Project project = new Project(); | ||
project.setDatasetCollection(Arrays.asList(fsDataset)); | ||
project.setDatasetSharedWithCollection(new ArrayList<>()); | ||
|
||
List<Featurestore> projectFeaturestores = featurestoreController.getProjectFeaturestores(project); | ||
Assert.assertEquals(0, projectFeaturestores.size()); | ||
} | ||
|
||
} |