Created
June 19, 2018 13:48
-
-
Save matzew/138ecb821ebf4d6c971cebff0d417ca1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// given | |
final Map<String, Object> storagePayload = (MAPPER.readValue(Thread.currentThread().getContextClassLoader().getResourceAsStream("pvc.json"), Map.class)); | |
final CloudEvent<Map<String, Object>> storageCloudEventWrapper = new CloudEventBuilder<Map<String, Object>>() | |
.eventType("ProvisioningSucceeded") | |
.eventTypeVersion("2.0") | |
.source(URI.create("/scheduler")) | |
.eventID(UUID.randomUUID().toString()) | |
.data(storagePayload) | |
.build(); | |
// when | |
final String httpSerializedPayload = MAPPER.writeValueAsString(storageCloudEventWrapper); | |
assertThat(httpSerializedPayload).contains("PersistentVolumeClaim"); | |
//PARSE into real object, on the other side | |
final CloudEvent<GlusterVolumeClaim> event = MAPPER.readValue(httpSerializedPayload, new TypeReference<CloudEvent<GlusterVolumeClaim>>() {}); | |
// then | |
assertThat(event.getData().get()).isNotNull(); | |
assertThat(event.getData().get().getSpec().getCapacity().get("storage")).isEqualTo("2Gi"); | |
assertThat(event.getData().get().getSpec().getAccessModes()).containsExactly("ReadWriteMany"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment