Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reenable disabled unit test and fix bugs #1608

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,16 @@ public <T extends Resource> T init(ResourceIdentifier<T> id, PreparedResources p
List<ResourceMetadata<? extends Resource>> mdList = new ArrayList<ResourceMetadata<? extends Resource>>();
ResourceMetadata<? extends Resource> md = resourceMetadata.get(id);
mdList.add(md);
graph.insertNode(md);
List<ResourceMetadata<? extends Resource>> dependencies = new ArrayList<ResourceMetadata<?>>();
WorkspaceUtils.collectDependencies(dependencies, graph.getNode(id));
mdList.addAll(dependencies);
for (ResourceIdentifier<?> dependencyId : md.getDependencies()) {
ResourceMetadata<? extends Resource> dependencyMd = resourceMetadata.get(dependencyId);
mdList.add(dependencyMd);
}
for (ResourceIdentifier<?> dependencyId : md.getSoftDependencies()) {
ResourceMetadata<? extends Resource> dependencyMd = resourceMetadata.get(dependencyId);
if (dependencyMd != null) {
mdList.add(dependencyMd);
}
}

ResourceGraph g = new ResourceGraph(mdList);
mdList = g.toSortedList();
Expand All @@ -380,6 +386,7 @@ public <T extends Resource> T init(ResourceIdentifier<T> id, PreparedResources p
LOG.info("Resource {} already available.", metadata.getIdentifier());
continue;
}
graph.insertNode(metadata);
ResourceBuilder<? extends Resource> builder = prepared.getBuilder(metadata.getIdentifier());
LOG.info("Building resource {}.", metadata.getIdentifier());
try {
Expand Down Expand Up @@ -518,7 +525,7 @@ public <T extends Resource> void add(ResourceLocation<T> location) {

@Override
public <T extends Resource> void destroy(ResourceIdentifier<T> id) {
List<ResourceIdentifier<T>> resourcesToRemove = collectResourcesToDestroy(id);
List<ResourceIdentifier<?>> resourcesToRemove = collectResourcesToDestroy(id);

for (ResourceIdentifier resourceId : resourcesToRemove) {
T res = (T) resources.get(resourceId);
Expand All @@ -534,14 +541,14 @@ public <T extends Resource> void destroy(ResourceIdentifier<T> id) {
}
}

private <T extends Resource> List<ResourceIdentifier<T>> collectResourcesToDestroy(ResourceIdentifier<T> id) {
List<ResourceIdentifier<T>> resourcesToRemove = new ArrayList<>();
ResourceNode<T> node = graph.getNode(id);
private List<ResourceIdentifier<?>> collectResourcesToDestroy(ResourceIdentifier<?> id) {
List<ResourceIdentifier<?>> resourcesToRemove = new ArrayList<>();
ResourceNode<?> node = graph.getNode(id);
if (node == null) {
return resourcesToRemove;
}
for (ResourceNode<? extends Resource> n : node.getDependents()) {
collectResourcesToDestroy(n.getMetadata().getIdentifier());
resourcesToRemove.addAll(collectResourcesToDestroy(n.getMetadata().getIdentifier()));
}
resourcesToRemove.add(id);
return resourcesToRemove;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ public void testResourceGraph() {
}

@Test
@Ignore
public void testDestroySingle() {
FeatureStore fs = workspace.getResource(FeatureStoreProvider.class, "simplesql-ok");
Assert.assertNotNull("Feature store is expected to be created.", fs);
Expand All @@ -144,7 +143,6 @@ public void testDestroySingle() {
}

@Test
@Ignore
public void testDestroyInitializeSingle() {
FeatureStore fs = workspace.getResource(FeatureStoreProvider.class, "simplesql-ok");
Assert.assertNotNull("Feature store is expected to be created.", fs);
Expand All @@ -158,7 +156,6 @@ public void testDestroyInitializeSingle() {
}

@Test
@Ignore
public void testReinitializeChain() {
FeatureStore fs = workspace.getResource(FeatureStoreProvider.class, "simplesql-ok");
Assert.assertNotNull("Feature store is expected to be created.", fs);
Expand Down