Browse Source

Fix error in tests for SystemPatchApplier

pull/14376/head
Andrii Landiak 10 months ago
parent
commit
b63822b8e5
  1. 16
      application/src/test/java/org/thingsboard/server/controller/AbstractWebTest.java
  2. 2
      common/data/src/main/java/org/thingsboard/server/common/data/pat/ApiKey.java
  3. 20
      common/data/src/main/java/org/thingsboard/server/common/data/pat/ApiKeyInfo.java
  4. 1
      dao/src/test/java/org/thingsboard/server/dao/service/ApiKeyServiceTest.java

16
application/src/test/java/org/thingsboard/server/controller/AbstractWebTest.java

@ -38,8 +38,6 @@ import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.http.HttpHeaders;
@ -53,6 +51,8 @@ import org.springframework.mock.http.MockHttpInputMessage;
import org.springframework.mock.http.MockHttpOutputMessage;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.mock.web.MockPart;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.context.bean.override.mockito.MockitoSpyBean;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
@ -167,6 +167,7 @@ import org.thingsboard.server.service.entitiy.tenant.profile.TbTenantProfileServ
import org.thingsboard.server.service.security.auth.jwt.RefreshTokenRequest;
import org.thingsboard.server.service.security.auth.rest.LoginRequest;
import org.thingsboard.server.service.security.model.token.JwtTokenFactory;
import org.thingsboard.server.service.system.SystemPatchApplier;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@ -295,18 +296,21 @@ public abstract class AbstractWebTest extends AbstractInMemoryStorageTest {
@Autowired
private JwtTokenFactory jwtTokenFactory;
@SpyBean
protected MailService mailService;
@Autowired
protected InMemoryStorage storage;
@Autowired
protected JdbcTemplate jdbcTemplate;
@MockBean
@MockitoSpyBean
protected MailService mailService;
@MockitoBean
protected CfRocksDb cfRocksDb;
@MockitoBean
protected SystemPatchApplier systemPatchApplier;
@Rule
public TestRule watcher = new TestWatcher() {
protected void starting(Description description) {

2
common/data/src/main/java/org/thingsboard/server/common/data/pat/ApiKey.java

@ -32,7 +32,7 @@ public class ApiKey extends ApiKeyInfo {
private static final long serialVersionUID = -2313196723950490263L;
@NoXss
@Schema(description = "Api key value", requiredMode = Schema.RequiredMode.REQUIRED)
@Schema(description = "API key value", requiredMode = Schema.RequiredMode.REQUIRED)
private String value;
public ApiKey() {

20
common/data/src/main/java/org/thingsboard/server/common/data/pat/ApiKeyInfo.java

@ -38,26 +38,26 @@ public class ApiKeyInfo extends BaseData<ApiKeyId> implements HasTenantId {
@Serial
private static final long serialVersionUID = -2313196723950490263L;
@Schema(description = "JSON object with Tenant Id. Tenant Id of the api key cannot be changed.", accessMode = Schema.AccessMode.READ_ONLY)
@Schema(description = "JSON object with Tenant Id. Tenant Id of the API key cannot be changed.", accessMode = Schema.AccessMode.READ_ONLY)
private TenantId tenantId;
@Schema(description = "JSON object with User Id. User Id of the api key cannot be changed.")
@Schema(description = "JSON object with User Id. User Id of the API key cannot be changed.")
private UserId userId;
@Schema(description = "Expiration time of the api key.")
@Schema(description = "Expiration time of the API key.")
private long expirationTime;
@NoXss
@NotBlank
@Length(fieldName = "description")
@Schema(description = "Api Key description.", example = "Api Key description")
@Schema(description = "API Key description.", example = "API Key description")
private String description;
@Schema(description = "Enabled/disabled api key.", example = "true")
@Schema(description = "Enabled/disabled API key.", example = "true")
private boolean enabled;
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
@Schema(description = "Indicates if the api key is expired based on current time. Returns false if expirationTime is 0 (no expiry).",
@Schema(description = "Indicates if the API key is expired based on current time. Returns false if expirationTime is 0 (no expiry).",
example = "false",
accessMode = Schema.AccessMode.READ_ONLY)
public boolean isExpired() {
@ -67,10 +67,10 @@ public class ApiKeyInfo extends BaseData<ApiKeyId> implements HasTenantId {
return System.currentTimeMillis() > expirationTime;
}
@Schema(description = "JSON object with the Api Key Id. " +
"Specify this field to update the Api Key. " +
"Referencing non-existing Api Key Id will cause error. " +
"Omit this field to create new Api Key.")
@Schema(description = "JSON object with the API Key Id. " +
"Specify this field to update the API Key. " +
"Referencing non-existing API Key Id will cause error. " +
"Omit this field to create new API Key.")
@Override
public ApiKeyId getId() {
return super.getId();

1
dao/src/test/java/org/thingsboard/server/dao/service/ApiKeyServiceTest.java

@ -42,6 +42,7 @@ public class ApiKeyServiceTest extends AbstractServiceTest {
@Autowired
ApiKeyService apiKeyService;
@Autowired
UserService userService;

Loading…
Cancel
Save