Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parse virtual-host-gatherer null value #7282

Merged
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
12 changes: 10 additions & 2 deletions java/code/src/com/suse/manager/gatherer/GathererJsonIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.google.gson.TypeAdapter;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;

import java.io.IOException;
Expand Down Expand Up @@ -100,11 +101,18 @@ public GathererModule read(JsonReader reader) throws IOException {
reader.beginObject();
while (reader.hasNext()) {
String key = reader.nextName();
String value = null;
if (reader.peek() == JsonToken.NULL) {
reader.nextNull();
}
else {
value = reader.nextString();
}
if (key.equals("module")) {
gm.setName(reader.nextString());
gm.setName(value);
}
else {
gm.addParameter(key, reader.nextString());
gm.addParameter(key, value);
}
}
reader.endObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ public void testReadGathererModules() throws Exception {
FileUtils.readStringFromFile(TestUtils.findTestData(MODULELIST).getPath());
Map<String, GathererModule> mods = new GathererJsonIO().readGathererModules(json);

assertEquals(2, mods.keySet().size());
assertEquals(3, mods.keySet().size());
assertTrue(mods.keySet().contains("VMware"));
assertTrue(mods.keySet().contains("SUSECloud"));
assertTrue(mods.keySet().contains("Libvirt"));

for (GathererModule g : mods.values()) {
if (g.getName().equals("VMware")) {
Expand All @@ -76,6 +77,11 @@ else if (g.getName().equals("SUSECloud")) {
assertTrue(g.getParameters().containsKey("protocol"));
assertTrue(g.getParameters().containsKey("tenant"));
}
else if (g.getName().equals("Libvirt")) {
assertTrue(g.getParameters().containsKey("uri"));
assertTrue(g.getParameters().containsKey("sasl_username"));
assertTrue(g.getParameters().containsKey("sasl_password"));
}
else {
fail("Unknown Module");
}
Expand Down
6 changes: 6 additions & 0 deletions java/code/src/com/suse/manager/gatherer/test/modulelist.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
"port": 443,
"username": "",
"password": ""
},
"Libvirt": {
"module": "Libvirt",
"uri": "",
"sasl_username": null,
"sasl_password": null
}
}

1 change: 1 addition & 0 deletions java/spacewalk-java.changes.mbussolotto.parse_null
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- parse virtual-host-gatherer null value
Loading