package leshan.interop;

import static org.junit.Assert.*;

import java.util.HashMap;

import leshan.client.californium.impl.CaliforniumClientIdentifier;
import leshan.client.request.RegisterRequest;
import leshan.client.response.OperationResponse;
import leshan.server.client.Client;

import org.eclipse.californium.core.coap.CoAP.ResponseCode;
import org.junit.Test;

public class RegistrationTest extends BaseTest {

    @Test
    public void LightweightM2M_1_0_int_101_Initial_Registration() {
        System.out.println("## LightweightM2M-1.0-int-101 – Initial Registration");

        OperationResponse response = client.send(new RegisterRequest(clientEndpoint, new HashMap<String, String>()));
        System.out.println("Registration result: " + response);

        // verify registration on server side
        Client client = server.getClientRegistry().get(clientEndpoint);
        assertNotNull(client);
        System.out.println("Registered client: " + client);

        // verify the response received by the client
        assertEquals(ResponseCode.CREATED, response.getResponseCode());
        String location = ((CaliforniumClientIdentifier) response.getClientIdentifier()).getLocation().split("/")[2];
        assertEquals(client.getRegistrationId(), location);
    }

}

@@ -147,16 +147,64 @@
 tifier;%0A
+import leshan.client.request.DeregisterRequest;%0A
 import l
@@ -233,32 +233,32 @@
 egisterRequest;%0A
-
 import leshan.cl
@@ -868,17 +868,20 @@
  Client 
-c
+regC
 lient = 
@@ -950,17 +950,20 @@
 NotNull(
-c
+regC
 lient);%0A
@@ -1013,17 +1013,20 @@
 nt: %22 + 
-c
+regC
 lient);%0A
@@ -1291,17 +1291,20 @@
 tEquals(
-c
+regC
 lient.ge
@@ -1340,10 +1340,897 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void LightweightM2M_1_0_int_103_Deregistration() %7B%0A        System.out.println(%22## LightweightM2M-1.0-int-103 %E2%80%93 Deregistration%22);%0A%0A        // client registration%0A        OperationResponse regResponse = client.send(new RegisterRequest(clientEndpoint, new HashMap%3CString, String%3E()));%0A%0A        Client regClient = server.getClientRegistry().get(clientEndpoint);%0A        assertNotNull(regClient);%0A%0A        OperationResponse deregResponse = client.send(new DeregisterRequest(regResponse.getClientIdentifier()));%0A        System.out.println(%22Deregistration result: %22 + deregResponse);%0A%0A        // verify the response received by the client%0A        assertEquals(ResponseCode.DELETED, deregResponse.getResponseCode());%0A%0A        // verify the registration on server side%0A        regClient = server.getClientRegistry().get(clientEndpoint);%0A        assertNull(regClient);%0A    %7D%0A%0A
 %7D%0A

Add deregistration test