// A project's own applications (classes under projekt/anwendungen): Java // installs them when it loads the whole archive (tools/java-oracle, laden). // The reader keeps them as beans, without knowing what Java makes of them; // its test compares them by key and class. import { FILIUS_APPLICATION_CLASSES } from '../src/index.js'; /** The corpus files with an own application installed on a host. */ export const OWN_APPLICATION_FILES = ['java-examples/anwendung_komplett.fls', 'java-examples/multicast_server.fls']; type View = { nodes?: { system: Record }[] }; /** Java's view without the applications FILIUS does not ship. */ export function withoutOwnApplications(view: T): T { const { nodes } = view as View; if (nodes === undefined) return view; return { ...view, nodes: nodes.map((node) => node.system.applications === undefined ? node : { ...node, system: { ...node.system, applications: (node.system.applications as { class: string }[]).filter((application) => (FILIUS_APPLICATION_CLASSES as readonly string[]).includes(application.class), ), }, }, ), }; } /** Java's view with each own application as its key, class and whether it runs on its node's system software. */ export function withOwnApplicationsByClass(view: T): T { const { nodes } = view as View; if (nodes === undefined) return view; return { ...view, nodes: nodes.map((node) => node.system.applications === undefined ? node : { ...node, system: { ...node.system, applications: (node.system.applications as { key: string; class: string }[]).map((application) => (FILIUS_APPLICATION_CLASSES as readonly string[]).includes(application.class) ? application : { key: application.key, class: application.class, onItsSystem: (application as { onItsSystem?: boolean }).onItsSystem }, ), }, }, ), }; } /** Whether Java's view has an own application installed. */ export function hasOwnApplications(view: unknown): boolean { return JSON.stringify(withoutOwnApplications(view)) !== JSON.stringify(view); }