Skip to content
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
33 changes: 31 additions & 2 deletions api/src/main/java/com/emnify/sdk/model/Sim.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public class Sim {
@SerializedName(SERIALIZED_NAME_IMSI)
private String imsi;

public static final String SERIALIZED_NAME_ACTIVATE = "activate";
@SerializedName(SERIALIZED_NAME_ACTIVATE)
private Boolean activate;


public Sim id(Integer id) {

Expand Down Expand Up @@ -145,6 +149,29 @@ public void setImsi(String imsi) {
}


public Sim activate(Boolean activate) {

this.activate = activate;
return this;
}

/**
* Whether the SIM is activated when it is assigned to the endpoint. Defaults to true server-side, so pass false to assign the SIM without activating it. Left null the property is omitted from the request.
* @return activate
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "Whether the SIM is activated when it is assigned to the endpoint. Defaults to true server-side, so pass false to assign the SIM without activating it.")

public Boolean getActivate() {
return activate;
}


public void setActivate(Boolean activate) {
this.activate = activate;
}


@Override
public boolean equals(Object o) {
if (this == o) {
Expand All @@ -157,12 +184,13 @@ public boolean equals(Object o) {
return Objects.equals(this.id, sim.id) &&
Objects.equals(this.iccid, sim.iccid) &&
Objects.equals(this.msisdn, sim.msisdn) &&
Objects.equals(this.imsi, sim.imsi);
Objects.equals(this.imsi, sim.imsi) &&
Objects.equals(this.activate, sim.activate);
}

@Override
public int hashCode() {
return Objects.hash(id, iccid, msisdn, imsi);
return Objects.hash(id, iccid, msisdn, imsi, activate);
}

@Override
Expand All @@ -173,6 +201,7 @@ public String toString() {
sb.append(" iccid: ").append(toIndentedString(iccid)).append("\n");
sb.append(" msisdn: ").append(toIndentedString(msisdn)).append("\n");
sb.append(" imsi: ").append(toIndentedString(imsi)).append("\n");
sb.append(" activate: ").append(toIndentedString(activate)).append("\n");
sb.append("}");
return sb.toString();
}
Expand Down
21 changes: 21 additions & 0 deletions api/src/test/java/com/emnify/sdk/model/SimTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

package com.emnify.sdk.model;

import com.emnify.sdk.JSON;
import com.google.gson.Gson;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
Expand Down Expand Up @@ -80,4 +82,23 @@ public void imsiTest() {
// TODO: test imsi
}

/**
* Test that the property 'activate' reaches the request body.
*
* The API activates an assigned SIM by default, so a client that cannot
* send activate=false cannot assign a SIM without activating (and billing)
* it. Serialization goes through the same Gson instance ApiClient uses.
*/
@Test
public void activateIsSerializedTest() {
Gson gson = JSON.createGson().create();

Assert.assertEquals("{\"id\":250,\"activate\":false}",
gson.toJson(new Sim().id(250).activate(false)));
Assert.assertEquals("{\"id\":250,\"activate\":true}",
gson.toJson(new Sim().id(250).activate(true)));
// left unset the property is omitted, so the API default applies
Assert.assertEquals("{\"id\":250}", gson.toJson(new Sim().id(250)));
}

}
Loading