Skip to content

Commit

Permalink
fix: handle Dynamic Properties for API not in DEFAULT environment
Browse files Browse the repository at this point in the history
  • Loading branch information
gaetanmaisse committed Apr 24, 2023
1 parent a9736f8 commit 4fc33b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Expand Up @@ -143,7 +143,7 @@ private void startDynamicProperties(ApiEntity api) {
}

EnvironmentEntity environment = environmentService.findById(api.getEnvironmentId());
ExecutionContext executionContext = new ExecutionContext(environment.getId(), environment.getOrganizationId());
ExecutionContext executionContext = new ExecutionContext(environment.getOrganizationId(), environment.getId());
DynamicPropertyUpdater updater = new DynamicPropertyUpdater(api, this.executor, executionContext);

if (dynamicPropertyService.getProvider() == DynamicPropertyProvider.HTTP) {
Expand Down
Expand Up @@ -58,6 +58,9 @@
@RunWith(MockitoJUnitRunner.class)
public class DynamicPropertiesServiceTest {

private static final String ORGANIZATION_ID = "d7794b03-cda5-47c3-a9d4-3960380edb3a";
private static final String ENVIRONMENT_ID = "a445364b-9573-44dd-a89e-6920d41b1dcd";

@Rule
public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort());

Expand Down Expand Up @@ -91,9 +94,9 @@ public class DynamicPropertiesServiceTest {
@Before
public void before() {
EnvironmentEntity environment = new EnvironmentEntity();
environment.setId("DEFAULT");
environment.setOrganizationId("DEFAULT");
when(environmentService.findById(eq(environment.getId()))).thenReturn(environment);
environment.setId(ENVIRONMENT_ID);
environment.setOrganizationId(ORGANIZATION_ID);
when(environmentService.findById(environment.getId())).thenReturn(environment);
}

@Test
Expand Down Expand Up @@ -201,7 +204,7 @@ public void shouldStopWhenUpdateApiAndTimerAlreadyRunning() throws Exception {

private ApiEntity createApiEntity() {
final ApiEntity apiEntity = new ApiEntity();
apiEntity.setEnvironmentId("DEFAULT");
apiEntity.setEnvironmentId(ENVIRONMENT_ID);
final Services services = new Services();
final DynamicPropertyService dynamicPropertyService = new DynamicPropertyService();

Expand Down

0 comments on commit 4fc33b7

Please sign in to comment.