Skip to content

Fix Failing Tests For Api Service #279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 13, 2023
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
2 changes: 1 addition & 1 deletion server/api-service/lowcoder-domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
</dependency>
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<artifactId>de.flapdoodle.embed.mongo.spring30x</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@Configuration
public class RedisRateLimiterConfig {

@Value("${spring.redis.url:redis}")
@Value("${spring.data.redis.url:redis}")
private String redis;

@Bean
Expand Down
2 changes: 1 addition & 1 deletion server/api-service/lowcoder-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
</dependency>
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<artifactId>de.flapdoodle.embed.mongo.spring30x</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ spring:
authentication-database: admin
auto-index-creation: false
uri: mongodb://localhost:27017/lowcoder?socketTimeoutMS=5000
redis:
url: redis://localhost:6379
redis:
url: redis://localhost:6379
main:
allow-bean-definition-overriding: true
allow-circular-references: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ spring:
data:
mongodb:
uri: ${MONGODB_URL:mongodb://localhost:27017/lowcoder?socketTimeoutMS=5000}
redis:
url: ${REDIS_URL:redis://localhost:6379}
redis:
url: ${REDIS_URL:redis://localhost:6379}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.lowcoder.api.application;


import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -23,6 +25,7 @@
import org.lowcoder.domain.permission.model.ResourceRole;
import org.lowcoder.sdk.exception.BizError;
import org.lowcoder.sdk.exception.BizException;
import org.pf4j.PluginManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
Expand All @@ -32,11 +35,10 @@
import java.util.List;
import java.util.Map;
import java.util.Set;

@Ignore
@SuppressWarnings({"OptionalGetWithoutIsPresent"})
@SpringBootTest
@RunWith(SpringRunner.class)
@Slf4j(topic = "ApplicationApiServiceTest")
public class ApplicationApiServiceTest {

@Autowired
Expand All @@ -48,6 +50,19 @@ public class ApplicationApiServiceTest {
@Autowired
private DatasourceApiService datasourceApiService;

@Autowired
private PluginManager pluginManager;

@Before
public void init() {
try {
pluginManager.loadPlugins();
pluginManager.startPlugins();
} catch (Exception e) {
log.error("Failed to load/start plugins. Exception: " + e);
}
}

@Test
@WithMockUser
public void testAutoInheritFoldersPermissionsOnAppCreate() {
Expand Down Expand Up @@ -269,6 +284,7 @@ public void testPermissions() {
.verifyComplete();
}

@Ignore
@SuppressWarnings("ConstantConditions")
@Test
@WithMockUser(id = "user02")
Expand Down Expand Up @@ -301,6 +317,7 @@ public void testCreateApplicationSuccess() {
.verifyComplete();
}

@Ignore
@SuppressWarnings("ConstantConditions")
@Test
@WithMockUser(id = "user02")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.util.Map;
import java.util.Set;

@Ignore
@SpringBootTest
@RunWith(SpringRunner.class)
public class CompoundApplicationDslFilterTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.lowcoder.api.authentication;

import com.google.common.collect.Iterables;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.lowcoder.api.authentication.AuthenticationController.FormLoginRequest;
Expand Down Expand Up @@ -34,7 +33,6 @@
import static org.lowcoder.sdk.exception.BizError.INVALID_PASSWORD;
import static org.lowcoder.sdk.exception.BizError.USER_LOGIN_ID_EXIST;

@Ignore
@SpringBootTest
@RunWith(SpringRunner.class)
@ActiveProfiles("AuthenticationControllerTest")
Expand Down Expand Up @@ -84,7 +82,7 @@ public void testFormRegisterSuccess() {
assertEquals(email, connection.getRawId());
assertEquals(email, connection.getName());
assertNull(connection.getAvatar());
assertEquals(1, connection.getOrgIds().size());
assertEquals(0, connection.getOrgIds().size());
assertNull(connection.getAuthConnectionAuthToken());
assertEquals(Map.of("email", email), connection.getRawUserInfo());
//exchange
Expand All @@ -95,7 +93,6 @@ public void testFormRegisterSuccess() {
})
.verifyComplete();
}

@Test
public void testFormLoginSuccess() {
String email = "test_login@ob.dev";
Expand Down Expand Up @@ -137,7 +134,7 @@ public void testFormLoginSuccess() {
assertEquals(email, connection.getRawId());
assertEquals(email, connection.getName());
assertNull(connection.getAvatar());
assertEquals(1, connection.getOrgIds().size());
assertEquals(0, connection.getOrgIds().size());
assertNull(connection.getAuthConnectionAuthToken());
assertEquals(Map.of("email", email), connection.getRawUserInfo());
//exchange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

import static org.junit.Assert.*;

@Ignore
@SpringBootTest
@RunWith(SpringRunner.class)
public class GoogleAuthenticateTest {
Expand All @@ -43,6 +42,7 @@ public class GoogleAuthenticateTest {
@Autowired
private AuthenticationService authenticationService;

@Ignore
@Test
public void testGoogleRegisterSuccess() {
String email = "test_register@ob.dev";
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void init() {
@SuppressWarnings({"ConstantConditions"})
private void execute() {

String currentDirPath = JsonFileReader.buildPath("com/lowcoder/api/common/json");
String currentDirPath = JsonFileReader.buildPath("org/lowcoder/api/common/json");
File dir = new File(currentDirPath);
Stream.of(dir.listFiles())
.filter(file -> file.isFile() && file.getName().endsWith(".json"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
import static org.lowcoder.domain.permission.model.ResourceRole.OWNER;
import static org.lowcoder.domain.permission.model.ResourceRole.VIEWER;

@Ignore
@SpringBootTest
@RunWith(SpringRunner.class)
public class DatasourceApiServiceTest {

@Autowired
private DatasourceApiService datasourceApiService;

@Ignore
@Test
@WithMockUser(id = "user02")
public void testListOrgDatasource() {
Expand Down Expand Up @@ -62,6 +62,7 @@ private DatasourceView findDatasourceView(Collection<DatasourceView> datasourceV
.orElse(null);
}

@Ignore
@Test
@WithMockUser
public void testGrantPermissionAndGetPermissionSuccess() {
Expand Down Expand Up @@ -89,6 +90,7 @@ public void testGrantPermissionAndGetPermissionSuccess() {
.verifyComplete();
}

@Ignore
@Test
@WithMockUser
public void testUpdatePermissionAndDeletePermissionSuccess() {
Expand Down Expand Up @@ -126,6 +128,7 @@ public void testUpdatePermissionAndDeletePermissionSuccess() {
.verifyComplete();
}

@Ignore
@Test
@WithMockUser(id = "user02")
public void testUpdatePermissionErrorWithNoPermission() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import static org.junit.jupiter.api.Assertions.assertEquals;

@Ignore
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import static org.lowcoder.api.common.mockuser.WithMockUser.DEFAULT_CURRENT_ORG_ID;

@Ignore
@SuppressWarnings("SameParameterValue")
@SpringBootTest
@RunWith(SpringRunner.class)
Expand All @@ -32,6 +31,7 @@ public class LibraryQueryApiServiceTest {
@Autowired
private LibraryQueryApiService libraryQueryApiService;

@Ignore
@Test
@WithMockUser
public void testListLibraryQueries() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import static org.junit.Assert.assertEquals;

@Ignore
@SpringBootTest
@RunWith(SpringRunner.class)
public class FolderApiServiceTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import lombok.extern.slf4j.Slf4j;
import reactor.test.StepVerifier;

@Ignore
@SuppressWarnings({"ReactiveStreamsNullableInLambdaInTransform"})
@RunWith(SpringRunner.class)
@SpringBootTest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
spring:
mongodb:
embedded:
version: 4.0.2
main:
allow-circular-references: true
redis:
url: redis://localhost:6370
data:
redis:
url: redis://localhost:6370

de:
flapdoodle:
mongodb:
embedded:
version: 4.0.2

server:
port: 8080
Expand All @@ -17,4 +21,13 @@ demo:
port: 3306
timeout: 100
username: 123
host: localhost
host: localhost

common:
cookie-name: UT-TACO-TOKEN

auth:
email:
enable: true
google:
enable: true
2 changes: 1 addition & 1 deletion server/api-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@
</dependency>
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<artifactId>de.flapdoodle.embed.mongo.spring30x</artifactId>
<version>4.7.0</version>
</dependency>
<dependency>
Expand Down