asset metadata form added
This commit is contained in:
+9
-2
@@ -191,7 +191,10 @@ final class FileSystemPackerWorkspaceServiceTest {
|
||||
OutputCodecCatalog.NONE,
|
||||
Map.of(
|
||||
"NONE:packMode", "tight",
|
||||
"NONE:palette", "mono")));
|
||||
"NONE:palette", "mono"),
|
||||
Map.of(
|
||||
"tile_size", "16",
|
||||
"channels", "1")));
|
||||
|
||||
assertTrue(result.success());
|
||||
assertNull(result.errorMessage());
|
||||
@@ -202,6 +205,8 @@ final class FileSystemPackerWorkspaceServiceTest {
|
||||
assertEquals("NONE", manifest.path("output").path("codec").asText());
|
||||
assertEquals("tight", manifest.path("output").path("codec_configuration").path("packMode").asText());
|
||||
assertEquals("mono", manifest.path("output").path("codec_configuration").path("palette").asText());
|
||||
assertEquals("16", manifest.path("output").path("metadata").path("tile_size").asText());
|
||||
assertEquals("1", manifest.path("output").path("metadata").path("channels").asText());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -218,7 +223,8 @@ final class FileSystemPackerWorkspaceServiceTest {
|
||||
AssetReference.forAssetId(1),
|
||||
false,
|
||||
OutputCodecCatalog.NONE,
|
||||
Map.of("NONE:packMode", "tight")));
|
||||
Map.of("NONE:packMode", "tight"),
|
||||
Map.of()));
|
||||
|
||||
assertTrue(updateResult.success());
|
||||
assertEquals(1, loader.loadCount());
|
||||
@@ -243,6 +249,7 @@ final class FileSystemPackerWorkspaceServiceTest {
|
||||
AssetReference.forAssetId(1),
|
||||
true,
|
||||
OutputCodecCatalog.NONE,
|
||||
Map.of(),
|
||||
Map.of()));
|
||||
|
||||
assertFalse(result.success());
|
||||
|
||||
+26
@@ -1,6 +1,7 @@
|
||||
package p.packer.services;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import p.packer.messages.AssetReference;
|
||||
@@ -16,6 +17,7 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@@ -57,6 +59,30 @@ final class PackerAssetDetailsServiceTest {
|
||||
assertEquals(List.of(), result.details().codecConfigurationFieldsByCodec().get(OutputCodecCatalog.NONE));
|
||||
}
|
||||
|
||||
@Test
|
||||
void exposesMetadataFieldsFromOutputMetadataContract() throws Exception {
|
||||
final Path projectRoot = copyFixture("workspaces/managed-basic", tempDir.resolve("managed-with-metadata"));
|
||||
final Path manifestPath = projectRoot.resolve("assets/ui/atlas/asset.json");
|
||||
|
||||
final ObjectMapper mapper = new ObjectMapper();
|
||||
final var manifest = mapper.readTree(manifestPath.toFile());
|
||||
final ObjectNode output = (ObjectNode) manifest.path("output");
|
||||
final ObjectNode metadata = output.putObject("metadata");
|
||||
metadata.put("tile_size", "16");
|
||||
metadata.put("channels", "1");
|
||||
mapper.writerWithDefaultPrettyPrinter().writeValue(manifestPath.toFile(), manifest);
|
||||
|
||||
final PackerAssetDetailsService service = service();
|
||||
final var result = service.getAssetDetails(new GetAssetDetailsRequest(project(projectRoot), AssetReference.forAssetId(1)));
|
||||
|
||||
assertEquals(PackerOperationStatus.SUCCESS, result.status());
|
||||
assertEquals(
|
||||
Map.of("tile_size", "16", "channels", "1"),
|
||||
result.details().metadataFields().stream().collect(java.util.stream.Collectors.toMap(
|
||||
field -> field.key(),
|
||||
field -> field.value())));
|
||||
}
|
||||
|
||||
@Test
|
||||
void returnsInvalidDetailsForInvalidDeclaration() throws Exception {
|
||||
final Path projectRoot = copyFixture("workspaces/invalid-missing-fields", tempDir.resolve("invalid"));
|
||||
|
||||
Reference in New Issue
Block a user