-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not connect backward dependencies to listener when invalidate - Test
Signed-off-by: GONCALVES Bruno <[email protected]>
- Loading branch information
GONCALVES Bruno
committed
Apr 24, 2024
1 parent
a2b0dd6
commit 595bbed
Showing
6 changed files
with
131 additions
and
137 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
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
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
31 changes: 31 additions & 0 deletions
31
afs-core/src/test/java/com/powsybl/afs/WithDependencyFile.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,31 @@ | ||
package com.powsybl.afs; | ||
|
||
import com.powsybl.afs.storage.events.NodeEvent; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class WithDependencyFile extends ProjectFile { | ||
|
||
private static final String DEP_NAME = "dep"; | ||
|
||
private final DependencyCache<ProjectFile> cache = new DependencyCache<>(this, DEP_NAME, ProjectFile.class); | ||
final List<NodeEvent> events = new ArrayList<>(); | ||
|
||
WithDependencyFile(ProjectFileCreationContext context) { | ||
super(context, 0); | ||
if (context.isConnected()) { | ||
context.getStorage().getEventsBus().addListener(eventList -> events.addAll(eventList.getEvents())); | ||
} | ||
} | ||
|
||
ProjectFile getTicDependency() { | ||
return cache.getFirst().orElse(null); | ||
} | ||
|
||
void setFooDependency(FooFile foo) { | ||
setDependencies(DEP_NAME, Collections.singletonList(foo)); | ||
cache.invalidate(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
afs-core/src/test/java/com/powsybl/afs/WithDependencyFileBuilder.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,20 @@ | ||
package com.powsybl.afs; | ||
|
||
import com.powsybl.afs.storage.NodeGenericMetadata; | ||
import com.powsybl.afs.storage.NodeInfo; | ||
|
||
public class WithDependencyFileBuilder implements ProjectFileBuilder<WithDependencyFile> { | ||
|
||
private final ProjectFileBuildContext context; | ||
|
||
WithDependencyFileBuilder(ProjectFileBuildContext context) { | ||
this.context = context; | ||
} | ||
|
||
@Override | ||
public WithDependencyFile build() { | ||
NodeInfo info = context.getStorage().createNode(context.getFolderInfo().getId(), "WithDependencyFile", "WITH_DEPENDENCY_FILE", "", 0, new NodeGenericMetadata()); | ||
context.getStorage().setConsistent(info.getId()); | ||
return new WithDependencyFile(new ProjectFileCreationContext(info, context.getStorage(), context.getProject())); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
afs-core/src/test/java/com/powsybl/afs/WithDependencyFileExtension.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,29 @@ | ||
package com.powsybl.afs; | ||
|
||
public class WithDependencyFileExtension implements ProjectFileExtension<WithDependencyFile, WithDependencyFileBuilder> { | ||
|
||
@Override | ||
public Class<WithDependencyFile> getProjectFileClass() { | ||
return WithDependencyFile.class; | ||
} | ||
|
||
@Override | ||
public String getProjectFilePseudoClass() { | ||
return "WITH_DEPENDENCY_FILE"; | ||
} | ||
|
||
@Override | ||
public Class<WithDependencyFileBuilder> getProjectFileBuilderClass() { | ||
return WithDependencyFileBuilder.class; | ||
} | ||
|
||
@Override | ||
public WithDependencyFile createProjectFile(ProjectFileCreationContext context) { | ||
return new WithDependencyFile(context); | ||
} | ||
|
||
@Override | ||
public ProjectFileBuilder<WithDependencyFile> createProjectFileBuilder(ProjectFileBuildContext context) { | ||
return new WithDependencyFileBuilder(context); | ||
} | ||
} |