Skip to content

Commit

Permalink
Add unit tests for Registry collection properties deployment and lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
arunans23 committed Mar 15, 2024
1 parent bed241c commit 05922fa
Showing 1 changed file with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,46 @@ public void testRegistryResourceRead() throws IOException {
Assert.assertEquals("Media type should be as expected", "application/javascript", mediaType);
}

@Test
public void testRegistryPropertiesDeploymentAndLookup() throws IOException {

String filePath = "gov:/custom/payload/template.json";
String content = "{\"Hello\":\"World\"}";
Properties properties = new Properties();
properties.setProperty("token", "12345");
properties.setProperty("owner", "John");
microIntegratorRegistry.addNewNonEmptyResource(filePath, false, "application/json", content, properties);

File resourceFile = Paths.get(governanceRegistry.toString(), "custom", "payload", "template.json").toFile();
File propertiesFile = Paths.get(governanceRegistry.toString(), "custom", "payload", "template.json.properties").toFile();
Assert.assertTrue("template.json file should be created", resourceFile.exists());
Assert.assertTrue("template.json.properties file should be created", propertiesFile.exists());

Properties readProperties = microIntegratorRegistry.getResourceProperties(filePath);
Assert.assertEquals("Properties should be as expected", "12345", readProperties.getProperty("token"));
Assert.assertEquals("Properties should be as expected", "John", readProperties.getProperty("owner"));

}

@Test
public void testRegistryCollectionPropertiesDeploymentAndLookup() throws IOException {

String filePath = "gov:/custom/folder";
Properties properties = new Properties();
properties.setProperty("token", "12345");
properties.setProperty("owner", "John");
microIntegratorRegistry.addNewNonEmptyResource(filePath, true, "application/json", "", properties);

File propertiesFile = Paths.get(governanceRegistry.toString(), "custom", "folder.collections.properties").toFile();
Assert.assertTrue("folder.collection.properties file should be created", propertiesFile.exists());

Properties readProperties = microIntegratorRegistry.getResourceProperties(filePath);
Assert.assertEquals("Properties should be as expected", "12345", readProperties.getProperty("token"));
Assert.assertEquals("Properties should be as expected", "John", readProperties.getProperty("owner"));

microIntegratorRegistry.delete(filePath);
}

@Test
public void testRegistryResourceReadWithEmptyMediaType() {
OMNode omNode = microIntegratorRegistry.lookup("conf:/custom/QueueName");
Expand Down

0 comments on commit 05922fa

Please sign in to comment.