Skip to content

Package: TranslatorAppKeystoreItemKuraKapua

TranslatorAppKeystoreItemKuraKapua

nameinstructionbranchcomplexitylinemethod
TranslatorAppKeystoreItemKuraKapua()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
translatePayload(KuraResponsePayload)
M: 29 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2021, 2022 Eurotech and/or its affiliates and others
3: *
4: * This program and the accompanying materials are made
5: * available under the terms of the Eclipse Public License 2.0
6: * which is available at https://www.eclipse.org/legal/epl-2.0/
7: *
8: * SPDX-License-Identifier: EPL-2.0
9: *
10: * Contributors:
11: * Eurotech - initial API and implementation
12: *******************************************************************************/
13: package org.eclipse.kapua.translator.kura.kapua.keystore;
14:
15: import org.eclipse.kapua.service.device.call.kura.model.keystore.KuraKeystoreItem;
16: import org.eclipse.kapua.service.device.call.message.kura.app.response.KuraResponseMessage;
17: import org.eclipse.kapua.service.device.call.message.kura.app.response.KuraResponsePayload;
18: import org.eclipse.kapua.service.device.management.keystore.internal.message.response.KeystoreItemResponseMessage;
19: import org.eclipse.kapua.service.device.management.keystore.internal.message.response.KeystoreResponsePayload;
20: import org.eclipse.kapua.translator.Translator;
21: import org.eclipse.kapua.translator.exception.InvalidPayloadException;
22:
23: /**
24: * {@link Translator} implementation from {@link KuraResponseMessage} to {@link KeystoreItemResponseMessage}
25: *
26: * @since 1.5.0
27: */
28: public class TranslatorAppKeystoreItemKuraKapua extends AbstractTranslatorAppKeystoreKuraKapua<KeystoreItemResponseMessage> {
29:
30: /**
31: * Constructor.
32: *
33: * @since 1.5.0
34: */
35: public TranslatorAppKeystoreItemKuraKapua() {
36: super(KeystoreItemResponseMessage.class);
37: }
38:
39: @Override
40: protected KeystoreResponsePayload translatePayload(KuraResponsePayload kuraResponsePayload) throws InvalidPayloadException {
41: try {
42: KeystoreResponsePayload keystoreResponsePayload = super.translatePayload(kuraResponsePayload);
43:
44:• if (kuraResponsePayload.hasBody()) {
45: KuraKeystoreItem kuraKeystoreItem = readJsonBodyAs(kuraResponsePayload.getBody(), KuraKeystoreItem.class);
46:
47: keystoreResponsePayload.setKeystoreItem(translate(kuraKeystoreItem));
48: }
49:
50: return keystoreResponsePayload;
51: } catch (Exception e) {
52: throw new InvalidPayloadException(e, kuraResponsePayload);
53: }
54: }
55: }