// A project's own applications (classes under projekt/anwendungen): Java // installs them when it loads the whole archive (tools/java-oracle, laden); // this package reads, writes and exports them in a later step (B2). Until // then the tests compare Java's views without them. 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), ), }, }, ), }; } /** Whether Java's view has an own application installed. */ export function hasOwnApplications(view: unknown): boolean { return JSON.stringify(withoutOwnApplications(view)) !== JSON.stringify(view); }