/
TestEvent.java
103 lines (83 loc) · 2.66 KB
/
TestEvent.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
* Copyright (c) 2017-2018 Bosch Software Innovations GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/index.php
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.signals.events.base.assertions;
import java.time.Instant;
import java.util.Optional;
import java.util.function.Predicate;
import javax.annotation.Nonnull;
import org.eclipse.ditto.json.JsonField;
import org.eclipse.ditto.json.JsonObject;
import org.eclipse.ditto.json.JsonPointer;
import org.eclipse.ditto.model.base.headers.DittoHeaders;
import org.eclipse.ditto.model.base.json.JsonParsableEvent;
import org.eclipse.ditto.model.base.json.JsonSchemaVersion;
import org.eclipse.ditto.signals.events.base.Event;
@JsonParsableEvent(name = TestEvent.NAME, typePrefix= TestEvent.TYPE_PREFIX)
public final class TestEvent implements Event<TestEvent> {
@SuppressWarnings("WeakerAccess") public static final String TYPE_PREFIX = "test.event.";
public static final String NAME = "type";
public static final String TYPE = TYPE_PREFIX + NAME;
private final String id;
private TestEvent(final String id) {
this.id = id;
}
@Override
public DittoHeaders getDittoHeaders() {
return DittoHeaders.empty();
}
@Override
public TestEvent setDittoHeaders(final DittoHeaders dittoHeaders) {
return new TestEvent(id);
}
@Override
public String getId() {
return id;
}
@Override
public JsonPointer getResourcePath() {
return JsonPointer.empty();
}
@Override
public String getResourceType() {
return "";
}
public static TestEvent fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) {
return new TestEvent("0");
}
public static TestEvent alternativeFromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) {
return new TestEvent("1");
}
@Override
public String getType() {
return TYPE;
}
@Override
public long getRevision() {
return 0;
}
@Override
public TestEvent setRevision(final long revision) {
return new TestEvent(id);
}
@Override
public Optional<Instant> getTimestamp() {
return Optional.empty();
}
@Nonnull
@Override
public String getManifest() {
return "";
}
@Override
public JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> predicate) {
return JsonObject.empty();
}
}