Skip to content

Commit

Permalink
Rework
Browse files Browse the repository at this point in the history
  • Loading branch information
Shubhangi-cs committed Dec 21, 2023
1 parent 08482c0 commit 50c9f4d
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 36 deletions.
1 change: 0 additions & 1 deletion docs/SuccessFactors-batchsource.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ You also can use the macro function ${conn(connection-name)}.
**Username:** Proxy username.
**Password:** Proxy password.


## Advance Option:

**Filter Options (M, O)**: Filter condition to restrict the output data volume e.g. Price gt 200
Expand Down
1 change: 0 additions & 1 deletion docs/SuccessFactors-connector.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Properties

**Password:** Proxy password.


Path of the connection
----------------------
To browse, get a sample from, or get the specification for this connection.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,19 @@ public class SuccessFactorsConnectorConfig extends PluginConfig {
@Name(PROPERTY_PROXY_URL)
@Description("Proxy URL. Must contain a protocol, address and port.")
@Macro
protected String proxyUrl;
private String proxyUrl;

@Nullable
@Name(PROPERTY_PROXY_USERNAME)
@Description("Proxy username.")
@Macro
protected String proxyUsername;
private String proxyUsername;

@Nullable
@Name(PROPERTY_PROXY_PASSWORD)
@Description("Proxy password.")
@Macro
protected String proxyPassword;
private String proxyPassword;

public SuccessFactorsConnectorConfig(String username, String password, String baseURL, String proxyUrl,
String proxyUsername, String proxyPassword) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ public class SuccessFactorsPluginConfig extends PluginConfig {
public static final String ENTITY_NAME = "entityName";
public static final String UNAME = "username";
public static final String PASSWORD = "password";
public static final String PROPERTY_PROXY_URL = "proxyUrl";
public static final String PROPERTY_PROXY_USERNAME = "proxyUsername";
public static final String PROPERTY_PROXY_PASSWORD = "proxyPassword";
private static final String REFERENCE_NAME = "referenceName";
private static final String REFERENCE_NAME_DESCRIPTION = "This will be used to uniquely identify this source/sink " +
"for lineage, annotating metadata, etc.";
Expand Down Expand Up @@ -222,8 +219,9 @@ public String getAdditionalQueryParameters() {
*/
public boolean isSchemaBuildRequired() {
return !(containsMacro(UNAME) || containsMacro(PASSWORD) || containsMacro(BASE_URL) || containsMacro(ENTITY_NAME)
|| containsMacro(PROPERTY_PROXY_URL) || containsMacro(PROPERTY_PROXY_USERNAME)
|| containsMacro(PROPERTY_PROXY_USERNAME));
|| containsMacro(SuccessFactorsConnectorConfig.PROPERTY_PROXY_URL)
|| containsMacro(SuccessFactorsConnectorConfig.PROPERTY_PROXY_USERNAME)
|| containsMacro(SuccessFactorsConnectorConfig.PROPERTY_PROXY_PASSWORD));
}

/**
Expand Down Expand Up @@ -313,7 +311,6 @@ public static class Builder {
private String proxyUsername;
private String proxyPassword;


public Builder referenceName(String referenceName) {
this.referenceName = referenceName;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@

import javax.ws.rs.core.MediaType;




/**
* This {@code SuccessFactorsTransporter} class is used to
* make a rest web service call to the SAP SuccessFactors exposed services.
Expand All @@ -67,7 +64,6 @@ public class SuccessFactorsTransporter {

public SuccessFactorsTransporter(SuccessFactorsConnectorConfig pluginConfig) {
this.config = pluginConfig;

}

/**
Expand Down Expand Up @@ -187,7 +183,7 @@ private SuccessFactorsResponseContainer prepareResponseContainer(Response res) t
/**
* Prepares request for metadata and data calls.
*
// * @param mediaType supported types 'application/json' & 'application/xml'
* @param mediaType supported types 'application/json' & 'application/xml'
* @return Request
*/
private Request buildRequest(URL endpoint, String mediaType) {
Expand All @@ -199,13 +195,16 @@ private Request buildRequest(URL endpoint, String mediaType) {
.build();
}

/**
* Builds and configures an OkHttpClient.Builder with the specified proxy settings and authentication credentials.
*/
private OkHttpClient.Builder buildConfiguredClient(String proxyUrl, String proxyUsername, String proxyPassword)
throws MalformedURLException, TransportException {
OkHttpClient.Builder builder = getConfiguredClient();

if (proxyUrl != null && !proxyUrl.isEmpty()) {
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(new URL(proxyUrl).getHost(),
new URL(proxyUrl).getPort()));
URL url = new URL(proxyUrl);
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(url.getHost(), url.getPort()));
builder.proxy(proxy);

if (proxyUsername != null && !proxyUsername.isEmpty() && proxyPassword != null && !proxyPassword.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ public void testConfiguration() throws TransportException, SuccessFactorsService
.password("password");

pluginConfig = pluginConfigBuilder.build();
successFactorsTransporter = new SuccessFactorsTransporter(pluginConfig.getConnection());
}

@Test
public void testValidateSuccessfulConnection() throws TransportException, SuccessFactorsServiceException {
successFactorsTransporter = new SuccessFactorsTransporter(pluginConfig.getConnection());
new Expectations(SuccessFactorsUrlContainer.class, SuccessFactorsTransporter.class,
SuccessFactorsSchemaGenerator.class) {
{
Expand All @@ -102,7 +102,6 @@ public void testValidateSuccessfulConnection() throws TransportException, Succes
public void testValidateUnauthorisedConnection() throws TransportException, SuccessFactorsServiceException {
MockFailureCollector collector = new MockFailureCollector();
ConnectorContext context = new MockConnectorContext(new MockConnectorConfigurer());
successFactorsTransporter = new SuccessFactorsTransporter(pluginConfig.getConnection());
new Expectations(SuccessFactorsUrlContainer.class, SuccessFactorsTransporter.class,
SuccessFactorsSchemaGenerator.class) {
{
Expand All @@ -118,7 +117,6 @@ public void testValidateUnauthorisedConnection() throws TransportException, Succ
@Test
public void testValidateNotFoundConnection() throws TransportException, SuccessFactorsServiceException {
MockFailureCollector collector = new MockFailureCollector();
successFactorsTransporter = new SuccessFactorsTransporter(pluginConfig.getConnection());
new Expectations(SuccessFactorsUrlContainer.class, SuccessFactorsTransporter.class,
SuccessFactorsSchemaGenerator.class) {
{
Expand Down Expand Up @@ -151,7 +149,6 @@ private SuccessFactorsResponseContainer getNotFoundResponseContainer() {
public void testGenerateSpec() throws TransportException, IOException {
ConnectorContext context = new MockConnectorContext(new MockConnectorConfigurer());
MockFailureCollector collector = new MockFailureCollector();
successFactorsTransporter = new SuccessFactorsTransporter(pluginConfig.getConnection());
new Expectations(SuccessFactorsTransporter.class) {
{
successFactorsTransporter.callSuccessFactorsEntity(null, anyString, anyString);
Expand Down Expand Up @@ -186,7 +183,6 @@ public void testGenerateSpecWithSchema() throws TransportException, IOException,
ConnectorContext context = new MockConnectorContext(new MockConnectorConfigurer());
MockFailureCollector collector = new MockFailureCollector();
successFactorsConnector = new SuccessFactorsConnector(pluginConfig.getConnection());
successFactorsTransporter = new SuccessFactorsTransporter(pluginConfig.getConnection());
new Expectations(SuccessFactorsConnector.class, SuccessFactorsTransporter.class) {
{

Expand Down Expand Up @@ -227,7 +223,6 @@ public void testBrowse() throws IOException, TransportException {
ConnectorContext context = new MockConnectorContext(new MockConnectorConfigurer());
List<String> entities = new ArrayList<>();
entities.add("Achievement");
successFactorsTransporter = new SuccessFactorsTransporter(pluginConfig.getConnection());
successFactorsConnector = new SuccessFactorsConnector(pluginConfig.getConnection());

new Expectations(SuccessFactorsTransporter.class, SuccessFactorsTransporter.class, SuccessFactorsConnector.class) {
Expand Down Expand Up @@ -261,7 +256,6 @@ public void testBrowse() throws IOException, TransportException {
@Test(expected = IOException.class)
public void testSampleWithoutSampleData() throws IOException, TransportException {
ConnectorContext context = new MockConnectorContext(new MockConnectorConfigurer());
successFactorsTransporter = new SuccessFactorsTransporter(pluginConfig.getConnection());
new Expectations(SuccessFactorsTransporter.class, SuccessFactorsTransporter.class, SuccessFactorsConnector.class) {
{
successFactorsTransporter.callSuccessFactorsEntity(null, anyString, anyString);
Expand All @@ -284,7 +278,6 @@ public void testSampleWithoutSampleData() throws IOException, TransportException
@Test
public void testSampleWithSampleData() throws IOException, TransportException, EntityProviderException,
SuccessFactorsServiceException, EdmException {
successFactorsTransporter = new SuccessFactorsTransporter(pluginConfig.getConnection());
String entityName = "entity";
List<StructuredRecord> records = new ArrayList<>();
StructuredRecord structuredRecord = Mockito.mock(StructuredRecord.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,17 @@ public class SuccessFactorsSchemaGeneratorTest {
public final ExpectedException exception = ExpectedException.none();
private SuccessFactorsEntityProvider serviceHelper;
private SuccessFactorsSchemaGenerator generator;
private SuccessFactorsPluginConfig pluginConfig;

@Before
public void setup() throws EntityProviderException {
edm = EntityProvider.readMetadata(TestSuccessFactorsUtil.readResource("successfactors-metadata.xml"), false);
serviceHelper = new SuccessFactorsEntityProvider(edm);
generator = new SuccessFactorsSchemaGenerator(serviceHelper);
pluginConfig = new SuccessFactorsPluginConfig("referenceName", "baseUR",
"entityName", "associateEntityName", "username", "password",
null, null, null, "filterOption", "selectOption",
"expandOption", "additionalQueryParameters", "paginationType");
}

@Test
Expand Down Expand Up @@ -78,11 +83,6 @@ public void testSelectWithExpandNames() throws SuccessFactorsServiceException {

@Test
public void testBuildExpandOutputSchema() throws SuccessFactorsServiceException {
SuccessFactorsPluginConfig pluginConfig = new SuccessFactorsPluginConfig("referenceName",
"baseUR", "entityName", "associateEntityName", "username",
"password", null, null, null, "filterOption",
"selectOption", "expandOption",
"additionalQueryParameters", "paginationType");
Schema outputSchema = generator.buildExpandOutputSchema("Benefit",
"eligibleBenefits", "associatedEntity", pluginConfig);
int lastIndex = outputSchema.getFields().size() - 1;
Expand Down Expand Up @@ -153,11 +153,6 @@ public void testInvalidEntityName() throws SuccessFactorsServiceException {

@Test
public void testInvalidExpandName() throws SuccessFactorsServiceException {
SuccessFactorsPluginConfig pluginConfig = new SuccessFactorsPluginConfig("referenceName",
"baseUR", "entityName", "associateEntityName", "username",
"password", null, null, null, "filterOption",
"selectOption", "expandOption", "additionalQueryParameters",
"paginationType");
exception.expectMessage("'assEntity' not found in the 'Benefit' entity.");
generator.buildExpandOutputSchema("Benefit", "INVALID-NAVIGATION-NAME",
"assEntity", pluginConfig);
Expand Down

0 comments on commit 50c9f4d

Please sign in to comment.