Skip to content

Commit

Permalink
Move path resolver model/apiWriter config to live adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
javiertuya committed Jan 4, 2025
1 parent 7989ea7 commit 197d527
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

<surefire.version>3.3.0</surefire.version>
<!--<tdrules.version>4.3.1</tdrules.version>-->
<tdrules.version>4.3.2-SNAPSHOT</tdrules.version>
<!--<tdrules.version>4.3.2-SNAPSHOT</tdrules.version>-->
<tdrules.version>4.3.2-next-release-SNAPSHOT</tdrules.version>
<qagrow.version>1.4.275</qagrow.version>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
import giis.tdrules.store.loader.IAttrGen;
import giis.tdrules.store.loader.gen.DictionaryAttrGen;
import giis.tdrules.store.loader.oa.ApiWriter;
import giis.tdrules.store.loader.oa.IPathResolver;
import giis.tdrules.store.loader.oa.OaLiveAdapter;
import giis.tdrules.store.loader.oa.OaPathResolver;
import giis.visualassert.Framework;
import giis.visualassert.VisualAssert;
import giis.visualassert.portable.FileUtil;
Expand Down Expand Up @@ -57,8 +55,8 @@ protected void load(ApiWriter writer, String query) {

// The path resolver is created using a controller mock (writer)
// and the data loader using a dictionary
IPathResolver pathResolver = new OaPathResolver().setSchemaModel(model).setServerUrl("").setApiWriter(writer);
DataLoader loader = new DataLoader(model, new OaLiveAdapter(pathResolver)).setAttrGen(getPetstoreDictionary().setMinYear(2024));
DataLoader loader = new DataLoader(model, new OaLiveAdapter("").setApiWriter(writer))
.setAttrGen(getPetstoreDictionary().setMinYear(2024));

// Generation and loading: Each test first delete all data previous to the generation and load
writer.delete("/test/deleteAll");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@
import giis.tdrules.store.loader.DataLoader;
import giis.tdrules.store.loader.IAttrGen;
import giis.tdrules.store.loader.oa.ApiWriter;
import giis.tdrules.store.loader.oa.IPathResolver;
import giis.tdrules.store.loader.oa.OaLiveAdapter;
import giis.tdrules.store.loader.oa.OaLocalAdapter;
import giis.tdrules.store.loader.oa.OaPathResolver;
import giis.tdrules.store.loader.oa.Reserializer;
import giis.visualassert.Framework;
import giis.visualassert.VisualAssert;
Expand Down Expand Up @@ -149,8 +147,7 @@ protected DataLoader getLocalDataLoader() {
}
protected DataLoader getLiveDataLoader() {
TdSchema model = getSchema();
IPathResolver pathResolver = new OaPathResolver().setSchemaModel(model);
return new DataLoader(model, new OaLiveAdapter(getServerUrl(), pathResolver));
return new DataLoader(model, new OaLiveAdapter(getServerUrl()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import giis.tdrules.store.loader.DataLoader;
import giis.tdrules.store.loader.IAttrGen;
import giis.tdrules.store.loader.gen.DictionaryAttrGen;
import giis.tdrules.store.loader.oa.IPathResolver;
import giis.tdrules.store.loader.oa.OaBasicAuthStore;
import giis.tdrules.store.loader.oa.OaLiveAdapter;
import giis.tdrules.store.loader.oa.OaLiveUidGen;
Expand Down Expand Up @@ -91,14 +90,13 @@ protected DataLoader getLiveDataLoader() {
// OrderDTO (username is userAccount attribute)
// * Use a dictionary
TdSchema model = getSchema();
IPathResolver pathResolver=new CustomPathResolver();
OaBasicAuthStore authenticator = new OaBasicAuthStore()
.setProvider("UserDTOReq", "email", "password")
.addConsumer(new String[] { "CartItemDTORes", "CartItemDTOReq",
"ContactsDTORes", "ContactsDTOReq" }, "user")
.addConsumer(new String[] { "OrderDTO"} , "userAccount");

return new DataLoader(model, new OaLiveAdapter(MARKET_URL_LIVE, pathResolver).setAuthStore(authenticator))
return new DataLoader(model, new OaLiveAdapter(MARKET_URL_LIVE).setPathResolver(new CustomPathResolver()).setAuthStore(authenticator))
.setUidGen(new OaLiveUidGen())
.setAttrGen(getDictionaryAttrGen());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class CustomPathResolver extends OaPathResolver {
@Override
public String getEndpointPath(String tableName) {
if ("Pet".equals(tableName) || "Category".equals(tableName))
return super.getEndpointPath("backid/" + tableName);
return "/backid/" + tableName.toLowerCase();
else
return super.getEndpointPath(tableName);
}
Expand All @@ -39,7 +39,7 @@ public String getEndpointPath(String tableName) {
@Override
protected DataLoader getLiveDataLoader() {
IPathResolver pathResolver=new CustomPathResolver();
return new DataLoader(getSchema(), new OaLiveAdapter(getServerUrl(), pathResolver)).setUidGen(new OaLiveUidGen());
return new DataLoader(getSchema(), new OaLiveAdapter(getServerUrl()).setPathResolver(pathResolver)).setUidGen(new OaLiveUidGen());
}

/**
Expand Down

0 comments on commit 197d527

Please sign in to comment.