7
7
import com .intellij .openapi .components .ServiceManager ;
8
8
import com .intellij .openapi .project .Project ;
9
9
import io .github .satr .common .*;
10
- import io .github .satr .idea .plugin .connector .la .entities .ArtifactEntry ;
11
- import io .github .satr .idea .plugin .connector .la .entities .CredentialProfileEntry ;
12
- import io .github .satr .idea .plugin .connector .la .entities .FunctionEntry ;
13
- import io .github .satr .idea .plugin .connector .la .entities .RegionEntry ;
10
+ import io .github .satr .idea .plugin .connector .la .entities .*;
14
11
import io .github .satr .idea .plugin .connector .la .models .ConnectorSettings ;
15
12
import io .github .satr .idea .plugin .connector .la .models .ProjectModel ;
16
13
import org .jetbrains .annotations .NotNull ;
17
14
18
15
import java .io .File ;
16
+ import java .nio .file .Files ;
19
17
import java .util .ArrayList ;
20
18
import java .util .Collection ;
21
- import java .util .Date ;
22
19
import java .util .List ;
23
20
24
21
import static org .apache .http .util .TextUtils .isEmpty ;
@@ -27,6 +24,7 @@ public class ConnectorPresenterImpl extends AbstractConnectorPresenter implement
27
24
private final Regions DEFAULT_REGION = Regions .US_EAST_1 ;
28
25
private ConnectorSettings connectorSettings = ConnectorSettings .getInstance ();
29
26
private ConnectorView view ;
27
+ private List <TestFunctionInputEntry > testFunctionInputRecentEntryList = new ArrayList <>();
30
28
31
29
@ Override
32
30
public void setView (ConnectorView view ) {
@@ -261,9 +259,41 @@ public void runFunctionTest(Project project, String inputText) {
261
259
}
262
260
263
261
@ Override
264
- public void openFunctionTestInputFile (String filename ) {
265
- view .logDebug ("Read function test input from file: %s" , filename );
266
- view .setFunctionTestInput ("input from file:" + filename );
262
+ public void openTestFunctionInputFile (File file ) {
263
+ try {
264
+ String filePath = file .getCanonicalPath ();
265
+ view .logDebug ("Read function test input from file: %s" , filePath );
266
+ byte [] buffer = Files .readAllBytes (file .toPath ());
267
+ String inputText = new String (buffer );
268
+ view .setTestFunctionInput (inputText );
269
+ for (TestFunctionInputEntry entry : testFunctionInputRecentEntryList ){
270
+ if (entry .getFilePath ().equals (filePath )){
271
+ testFunctionInputRecentEntryList .remove (entry );
272
+ break ;
273
+ }
274
+ }
275
+ testFunctionInputRecentEntryList .add (new TestFunctionInputEntry (filePath , file .getName (), inputText ));
276
+ view .setTestFunctionInputRecentEntryList (testFunctionInputRecentEntryList );
277
+ } catch (Exception e ) {
278
+ e .printStackTrace ();
279
+ view .logError (e );
280
+ }
281
+ }
282
+
283
+ @ Override
284
+ public String getLastSelectedTestFunctionInputFilePath () {
285
+ String filePath = connectorSettings .getLastSelectedTestFunctionInputFilePath ();
286
+ return isEmpty (filePath ) ? "" : filePath ;
287
+ }
288
+
289
+ @ Override
290
+ public void setLastSelectedTestFunctionInputFilePath (String path ) {
291
+ connectorSettings .setLastSelectedTestFunctionInputFilePath (path );
292
+ }
293
+
294
+ @ Override
295
+ public void setSetTestFunctionInputFromRecent (TestFunctionInputEntry entry ) {
296
+ view .setTestFunctionInput (entry .getInputText ());
267
297
}
268
298
269
299
private Regions tryGetRegionBy (String regionName ) {
0 commit comments