Skip to content

Commit

Permalink
fix(signalfx): Fixed metric type missing due to duplicated field from…
Browse files Browse the repository at this point in the history
… parent class (#957) (#958)

(cherry picked from commit 179492b)

Co-authored-by: Jason <[email protected]>
  • Loading branch information
mergify[bot] and jasonmcintosh authored Apr 13, 2023
1 parent bc7e3bf commit d2a4c79
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
import com.netflix.kayenta.retrofit.config.RemoteService;
import com.netflix.kayenta.security.AccountCredentials;
import com.netflix.kayenta.signalfx.service.SignalFxSignalFlowRemoteService;
import java.util.List;
import javax.validation.constraints.NotNull;
import lombok.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;

@Getter
Expand All @@ -34,8 +35,6 @@ public class SignalFxNamedAccountCredentials extends AccountCredentials<SignalFx

@NotNull private String name;

@NotNull @Singular private List<Type> supportedTypes;

@NotNull private SignalFxCredentials credentials;

@NotNull private RemoteService endpoint;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright 2023 Armory, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.netflix.kayenta.signalfx.config;

import static junit.framework.TestCase.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import com.netflix.kayenta.retrofit.config.RetrofitClientFactory;
import com.netflix.kayenta.security.AccountCredentials;
import com.netflix.kayenta.security.AccountCredentialsRepository;
import com.netflix.kayenta.security.MapBackedAccountCredentialsRepository;
import com.squareup.okhttp.OkHttpClient;
import java.util.List;
import org.junit.Test;

public class SignalFxConfigLoadTest {

private AccountCredentialsRepository accountRepo = new MapBackedAccountCredentialsRepository();

@Test
public void testThatConfigLoadFromAccountRendersCorrectly() {
SignalFxConfigurationProperties signalFxConfigurationProperties =
mock(SignalFxConfigurationProperties.class);
when(signalFxConfigurationProperties.getAccounts())
.thenReturn(List.of(new SignalFxManagedAccount().setName("Test-account")));
RetrofitClientFactory mockRetrofitFactory = mock(RetrofitClientFactory.class);
OkHttpClient mockOkHttpFactory = mock(OkHttpClient.class);
new SignalFxConfiguration()
.signalFxMetricService(
signalFxConfigurationProperties, mockRetrofitFactory, mockOkHttpFactory, accountRepo);
assertEquals("signalfx", accountRepo.getRequiredOne("Test-account").getType());
assertEquals(
List.of(AccountCredentials.Type.METRICS_STORE),
accountRepo.getRequiredOne("Test-account").getSupportedTypes());
}
}

0 comments on commit d2a4c79

Please sign in to comment.