@Test public void invalidStructureFails() throws Exception { JsonObject argumentsObj = new JsonObject(); argumentsObj.addProperty("namespace", "ns"); argumentsObj.addProperty("application", "app"); argumentsObj.addProperty("type", "WORKFLOW"); argumentsObj.add("name", new JsonObject()); BootstrapStepResult result = programStarter.execute("label", argumentsObj); Assert.assertEquals(BootstrapStepResult.Status.FAILED, result.getStatus()); } }
@Test public void testInvalidArgumentStructure() throws Exception { JsonObject arguments = new JsonObject(); arguments.addProperty("name", "p1"); arguments.addProperty("description", "desc"); arguments.addProperty("label", "some label"); // this is invalid, should be an object arguments.addProperty("provisioner", "native"); BootstrapStepResult result = profileCreator.execute("label", arguments); Assert.assertEquals(BootstrapStepResult.Status.FAILED, result.getStatus()); }
@Test public void invalidStructureFails() throws Exception { JsonObject argumentsObj = new JsonObject(); argumentsObj.addProperty("namespace", "ns"); argumentsObj.addProperty("name", "app"); argumentsObj.addProperty("artifact", "name-1.0.0"); BootstrapStepResult result = appCreator.execute("label", argumentsObj); Assert.assertEquals(BootstrapStepResult.Status.FAILED, result.getStatus()); } }
@Test public void testAllPreferenceSet() throws Exception { Map<String, String> preferences = new HashMap<>(); preferences.put("p1", "v1"); preferences.put("p2", "v2"); SystemPreferenceSetter.Arguments arguments = new SystemPreferenceSetter.Arguments(preferences); BootstrapStepResult result = systemPreferenceSetter.execute("label", GSON.toJsonTree(arguments).getAsJsonObject()); Assert.assertEquals(BootstrapStepResult.Status.SUCCEEDED, result.getStatus()); Assert.assertEquals(preferences, preferencesService.getProperties()); }
@Test public void testMissingProvisionerInfo() throws Exception { SystemProfileCreator.Arguments arguments = new SystemProfileCreator.Arguments("name", "label", "desc", null); BootstrapStepResult result = profileCreator.execute("label", GSON.toJsonTree(arguments).getAsJsonObject()); Assert.assertEquals(BootstrapStepResult.Status.FAILED, result.getStatus()); }
@Test public void testMissingProfileName() throws Exception { List<ProvisionerPropertyValue> properties = new ArrayList<>(); properties.add(new ProvisionerPropertyValue("name1", "val1", true)); properties.add(new ProvisionerPropertyValue("name2", "val2", true)); ProvisionerInfo provisionerInfo = new ProvisionerInfo(MockProvisioner.NAME, properties); SystemProfileCreator.Arguments arguments = new SystemProfileCreator.Arguments("", "label", "desc", provisionerInfo); BootstrapStepResult result = profileCreator.execute("label", GSON.toJsonTree(arguments).getAsJsonObject()); Assert.assertEquals(BootstrapStepResult.Status.FAILED, result.getStatus()); }
@Test public void testExistingIsUnmodified() throws Exception { Map<String, String> preferences = new HashMap<>(); preferences.put("p1", "v1"); preferencesService.setProperties(preferences); preferences.put("p2", "v2"); preferences.put("p1", "v3"); SystemPreferenceSetter.Arguments arguments = new SystemPreferenceSetter.Arguments(preferences); BootstrapStepResult result = systemPreferenceSetter.execute("label", GSON.toJsonTree(arguments).getAsJsonObject()); Assert.assertEquals(BootstrapStepResult.Status.SUCCEEDED, result.getStatus()); Map<String, String> expected = new HashMap<>(); // p1 should not have been overridden expected.put("p1", "v1"); expected.put("p2", "v2"); Assert.assertEquals(expected, preferencesService.getProperties()); } }