Skip to content
Merged
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
6 changes: 4 additions & 2 deletions docs/user-guide/asset-registry-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ content-cli asset-registry list
Example output:

```
BOARD_V2 - View [DASHBOARDS] (basePath: /blueprint/api)
SEMANTIC_MODEL - Knowledge Model [DATA_AND_PROCESS_MODELING] (basePath: /semantic-layer/api)
BOARD_V2 - View [DASHBOARDS]
SEMANTIC_MODEL - Knowledge Model [DATA_AND_PROCESS_MODELING] - Defines KPIs, records, filters, and data bindings for analytics
```

Each line is `<assetType> - <displayName> [<group>]` followed by ` - <description>` when the asset type provides one.

It is also possible to use the `--json` option for writing the full response to a file that gets created in the working directory.

```
Expand Down
9 changes: 6 additions & 3 deletions src/commands/asset-registry/asset-registry.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,12 @@ export class AssetRegistryService {
}

private logDescriptorSummary(descriptor: AssetRegistryDescriptor): void {
logger.info(
`${descriptor.assetType} - ${descriptor.displayName} [${descriptor.group}]`
);
const base = `${descriptor.assetType} - ${descriptor.displayName} [${descriptor.group}]`;
if (descriptor.description) {
logger.info(`${base} - ${descriptor.description}`);
} else {
logger.info(base);
}
}

private logDescriptorDetail(descriptor: AssetRegistryDescriptor): void {
Expand Down
43 changes: 35 additions & 8 deletions tests/commands/asset-registry/asset-registry-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,44 @@ describe("Asset registry list", () => {
},
};

it("Should list all asset types", async () => {
mockAxiosGet("https://myTeam.celonis.cloud/pacman/api/core/asset-registry/types", metadata);
it("Should render the description when it is present", async () => {
const withDescription: AssetRegistryMetadata = {
types: {
SEMANTIC_MODEL: metadata.types.SEMANTIC_MODEL,
},
};
mockAxiosGet(
"https://myTeam.celonis.cloud/pacman/api/core/asset-registry/types",
withDescription
);

await new AssetRegistryService(testContext).listTypes(false);

expect(loggingTestTransport.logMessages.length).toBe(1);
expect(loggingTestTransport.logMessages[0].message).toContain(
"SEMANTIC_MODEL - Knowledge Model [DATA_AND_PROCESS_MODELING] - Defines KPIs, records, filters, and data bindings for analytics"
);
});

it("Should omit the description when it is not present", async () => {
const withoutDescription: AssetRegistryMetadata = {
types: {
BOARD_V2: metadata.types.BOARD_V2
},
};
mockAxiosGet(
"https://myTeam.celonis.cloud/pacman/api/core/asset-registry/types",
withoutDescription
);

await new AssetRegistryService(testContext).listTypes(false);

expect(loggingTestTransport.logMessages.length).toBe(2);
expect(loggingTestTransport.logMessages[0].message).toContain("BOARD_V2");
expect(loggingTestTransport.logMessages[0].message).toContain("View");
expect(loggingTestTransport.logMessages[0].message).toContain("DASHBOARDS");
expect(loggingTestTransport.logMessages[1].message).toContain("SEMANTIC_MODEL");
expect(loggingTestTransport.logMessages[1].message).toContain("Knowledge Model");
expect(loggingTestTransport.logMessages.length).toBe(1);
expect(loggingTestTransport.logMessages[0].message).toContain(
"BOARD_V2 - View [DASHBOARDS]"
);
expect(loggingTestTransport.logMessages[0].message).not.toContain(" - null");
expect(loggingTestTransport.logMessages[0].message).not.toMatch(/\] - /);
});

it("Should list all asset types as JSON", async () => {
Expand Down
Loading