From 0504b7ce666da978da90da0d885e3f3e6ada68f8 Mon Sep 17 00:00:00 2001 From: akt0001c <110126989+akt0001c@users.noreply.github.com> Date: Tue, 5 Mar 2024 14:34:53 +0530 Subject: [PATCH] test cases update in wallet controller --- CabManagementSystem/.metadata/.log | 152 ++++++++++++++++++ .../.org.eclipse.egit.core.cmp/.location | Bin 241 -> 192 bytes .../.root/.indexes/properties.index | Bin 57 -> 151 bytes .../org.eclipse.core.resources/.root/1.tree | Bin 304 -> 0 bytes .../org.eclipse.core.resources/.root/2.tree | Bin 0 -> 304 bytes .../.safetable/org.eclipse.core.resources | Bin 679 -> 679 bytes .../org.eclipse.e4.workbench/workbench.xmi | 63 ++++++-- .../.plugins/org.eclipse.m2e.logback/0.log | 1 + .../logback.2.1.100.20230106-1511.xml | 41 +++++ .../.cache/clean-cache.properties | 2 +- .../org.eclipse.ui.ide/dialog_settings.xml | 33 ++++ CabManagementSystem/.metadata/version.ini | 4 +- .../main/java/com/safar/config/AppConfig.java | 1 + .../safar/controller/WalletController.java | 33 ++-- .../serviceImpl/WalletServicesImpl.java | 2 +- .../src/main/resources/application.properties | 2 +- .../controller/WalletControllerTest.java | 128 +++++++++++++++ 17 files changed, 430 insertions(+), 32 deletions(-) delete mode 100644 CabManagementSystem/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree create mode 100644 CabManagementSystem/.metadata/.plugins/org.eclipse.core.resources/.root/2.tree create mode 100644 CabManagementSystem/.metadata/.plugins/org.eclipse.m2e.logback/logback.2.1.100.20230106-1511.xml create mode 100644 CabManagementSystem/src/test/java/com/safar/controller/WalletControllerTest.java diff --git a/CabManagementSystem/.metadata/.log b/CabManagementSystem/.metadata/.log index b0b6aef..261ece4 100644 --- a/CabManagementSystem/.metadata/.log +++ b/CabManagementSystem/.metadata/.log @@ -57,3 +57,155 @@ user global configuration and to define the default location to store repositori not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and EGit might behave differently since they see different configuration options. This warning can be switched off on the Team > Git > Confirmations and Warnings preference page. +!SESSION 2024-01-10 12:36:34.121 ----------------------------------------------- +eclipse.buildId=4.18.1.202305021758 +java.version=17.0.7 +java.vendor=Eclipse Adoptium +BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_IN +Framework arguments: -product org.springframework.boot.ide.branding.sts4 +Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.springframework.boot.ide.branding.sts4 + +!ENTRY ch.qos.logback.classic 1 0 2024-01-10 12:36:35.233 +!MESSAGE Activated before the state location was initialized. Retry after the state location is initialized. + +!ENTRY org.eclipse.core.resources 4 567 2024-01-10 12:36:55.162 +!MESSAGE Workspace restored, but some problems occurred. +!SUBENTRY 1 org.eclipse.core.resources 4 567 2024-01-10 12:36:55.163 +!MESSAGE Could not read metadata for '.org.eclipse.egit.core.cmp'. +!STACK 1 +org.eclipse.core.internal.resources.ResourceException(/.org.eclipse.egit.core.cmp)[567]: java.lang.Exception: The project description file (.project) for '.org.eclipse.egit.core.cmp' is missing. This file contains important information about the project. The project will not function properly until this file is restored. + at org.eclipse.core.internal.resources.ResourceException.provideStackTrace(ResourceException.java:42) + at org.eclipse.core.internal.resources.ResourceException.(ResourceException.java:38) + at org.eclipse.core.internal.localstore.FileSystemResourceManager.read(FileSystemResourceManager.java:908) + at org.eclipse.core.internal.resources.SaveManager.restoreMetaInfo(SaveManager.java:894) + at org.eclipse.core.internal.resources.SaveManager.restoreMetaInfo(SaveManager.java:874) + at org.eclipse.core.internal.resources.SaveManager.restore(SaveManager.java:730) + at org.eclipse.core.internal.resources.SaveManager.startup(SaveManager.java:1584) + at org.eclipse.core.internal.resources.Workspace.startup(Workspace.java:2547) + at org.eclipse.core.internal.resources.Workspace.open(Workspace.java:2252) + at org.eclipse.core.resources.ResourcesPlugin$WorkspaceInitCustomizer.addingService(ResourcesPlugin.java:571) + at org.eclipse.core.resources.ResourcesPlugin$WorkspaceInitCustomizer.addingService(ResourcesPlugin.java:1) + at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:943) + at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:1) + at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256) + at org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:183) + at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:321) + at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:264) + at org.eclipse.core.resources.ResourcesPlugin.start(ResourcesPlugin.java:545) + at org.eclipse.osgi.internal.framework.BundleContextImpl$2.run(BundleContextImpl.java:818) + at org.eclipse.osgi.internal.framework.BundleContextImpl$2.run(BundleContextImpl.java:1) + at java.base/java.security.AccessController.doPrivileged(AccessController.java:569) + at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:810) + at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:767) + at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1032) + at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:371) + at org.eclipse.osgi.container.Module.doStart(Module.java:605) + at org.eclipse.osgi.container.Module.start(Module.java:468) + at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:513) + at org.eclipse.osgi.internal.hooks.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:117) + at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:570) + at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:335) + at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:397) + at org.eclipse.osgi.internal.loader.sources.SingleSourcePackage.loadClass(SingleSourcePackage.java:41) + at org.eclipse.osgi.internal.loader.BundleLoader.findClass0(BundleLoader.java:496) + at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:416) + at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:168) + at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) + at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:153) + at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659) + at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596) + at org.eclipse.equinox.launcher.Main.run(Main.java:1467) +!SUBENTRY 2 org.eclipse.core.resources 4 567 2024-01-10 12:36:55.163 +!MESSAGE The project description file (.project) for '.org.eclipse.egit.core.cmp' is missing. This file contains important information about the project. The project will not function properly until this file is restored. +!STACK 0 +java.lang.Exception: The project description file (.project) for '.org.eclipse.egit.core.cmp' is missing. This file contains important information about the project. The project will not function properly until this file is restored. + at org.eclipse.core.internal.resources.ResourceException.provideStackTrace(ResourceException.java:42) + at org.eclipse.core.internal.resources.ResourceException.(ResourceException.java:38) + at org.eclipse.core.internal.localstore.FileSystemResourceManager.read(FileSystemResourceManager.java:908) + at org.eclipse.core.internal.resources.SaveManager.restoreMetaInfo(SaveManager.java:894) + at org.eclipse.core.internal.resources.SaveManager.restoreMetaInfo(SaveManager.java:874) + at org.eclipse.core.internal.resources.SaveManager.restore(SaveManager.java:730) + at org.eclipse.core.internal.resources.SaveManager.startup(SaveManager.java:1584) + at org.eclipse.core.internal.resources.Workspace.startup(Workspace.java:2547) + at org.eclipse.core.internal.resources.Workspace.open(Workspace.java:2252) + at org.eclipse.core.resources.ResourcesPlugin$WorkspaceInitCustomizer.addingService(ResourcesPlugin.java:571) + at org.eclipse.core.resources.ResourcesPlugin$WorkspaceInitCustomizer.addingService(ResourcesPlugin.java:1) + at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:943) + at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:1) + at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256) + at org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:183) + at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:321) + at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:264) + at org.eclipse.core.resources.ResourcesPlugin.start(ResourcesPlugin.java:545) + at org.eclipse.osgi.internal.framework.BundleContextImpl$2.run(BundleContextImpl.java:818) + at org.eclipse.osgi.internal.framework.BundleContextImpl$2.run(BundleContextImpl.java:1) + at java.base/java.security.AccessController.doPrivileged(AccessController.java:569) + at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:810) + at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:767) + at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1032) + at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:371) + at org.eclipse.osgi.container.Module.doStart(Module.java:605) + at org.eclipse.osgi.container.Module.start(Module.java:468) + at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:513) + at org.eclipse.osgi.internal.hooks.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:117) + at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:570) + at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:335) + at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:397) + at org.eclipse.osgi.internal.loader.sources.SingleSourcePackage.loadClass(SingleSourcePackage.java:41) + at org.eclipse.osgi.internal.loader.BundleLoader.findClass0(BundleLoader.java:496) + at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:416) + at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:168) + at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) + at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:153) + at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659) + at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596) + at org.eclipse.equinox.launcher.Main.run(Main.java:1467) + +!ENTRY ch.qos.logback.classic 1 0 2024-01-10 12:36:55.610 +!MESSAGE Logback config file: D:\projects\onlinecabBookingApplication\Safar\CabManagementSystem\.metadata\.plugins\org.eclipse.m2e.logback\logback.2.1.100.20230106-1511.xml + +!ENTRY org.eclipse.jface 2 0 2024-01-10 12:36:57.521 +!MESSAGE Keybinding conflicts occurred. They may interfere with normal accelerator operation. +!SUBENTRY 1 org.eclipse.jface 2 0 2024-01-10 12:36:57.522 +!MESSAGE A conflict occurred for CTRL+SHIFT+T: +Binding(CTRL+SHIFT+T, + ParameterizedCommand(Command(org.eclipse.jdt.ui.navigate.open.type,Open Type, + Open a type in a Java editor, + Category(org.eclipse.ui.category.navigate,Navigate,null,true), + WorkbenchHandlerServiceHandler("org.eclipse.jdt.ui.navigate.open.type"), + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,,system) +Binding(CTRL+SHIFT+T, + ParameterizedCommand(Command(org.eclipse.lsp4e.symbolinworkspace,Go to Symbol in Workspace, + , + Category(org.eclipse.lsp4e.category,Language Servers,null,true), + WorkbenchHandlerServiceHandler("org.eclipse.lsp4e.symbolinworkspace"), + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,,system) + +!ENTRY org.eclipse.egit.ui 2 0 2024-01-10 12:36:59.953 +!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git +user global configuration and to define the default location to store repositories: 'C:\Users\ankit'. If this is +not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and +EGit might behave differently since they see different configuration options. +This warning can be switched off on the Team > Git > Confirmations and Warnings preference page. diff --git a/CabManagementSystem/.metadata/.plugins/org.eclipse.core.resources/.projects/.org.eclipse.egit.core.cmp/.location b/CabManagementSystem/.metadata/.plugins/org.eclipse.core.resources/.projects/.org.eclipse.egit.core.cmp/.location index d924b6c382340cdbdd879ce01b770ed9aa19b8ec..3d7c2ba81e346cab9bca30dd74c9bc2eed6b6a6c 100644 GIT binary patch delta 82 zcmey!c!1H%VPkir@*V~eDb;Du7f;?N$1ou@$WvcGEi)(8O5epwzn~~TD>b>KSU*26 mCo?ZKIWfs8KR-J&FWs@AASW|9u_QA;Pd_*@EwN}~br}E$#~*J1 delta 135 zcmX@W_>r;RVPkir@*V~eDb;Du7f;?N$8az-$WvcGEi)(8O5fQ^KeRZts93+av^XPE z-#;(ar6{v3Ro^AGIJ+dj04R`?nU|{ToS3BRl%JoSnU}5`oLW?tnVhN{o>`Ki8=99{ kq8pN0TmqEQPfJZKN-NFLP07#6(KWL$GuH>|o9I^r09}nSOaK4? diff --git a/CabManagementSystem/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index b/CabManagementSystem/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index index d23725117953ccb8c46434a9aa1306408ddc9166..cc1955fc7eeb3420df4b5c802aaf82ea14bf8586 100644 GIT binary patch literal 151 zcmYj~u?_+u5CtDtTWGZLBQPgoq_(%w*duN{jKF2t`+qN1SHGEg3V?#zW1+FD{5BN7 zX=r3(Wim{yjvT3B6>AYHatX1gn*<@KPE9hfolp0asY%EKmfgvFckHZp&K@*2^ZMr{ V{|BrmSm;6AQZ3gpKZ&93`3HK_ESmrT delta 17 YcmbQvXvxLMz`(%Bz^Ko_I59&X01@~CHvj+t diff --git a/CabManagementSystem/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree b/CabManagementSystem/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree deleted file mode 100644 index 4afac25183bdb452816415fcf4308ece84b453bf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 304 zcmZ9HITFG!3`ON7ECm%*RGdJUGQ#5w;EZh!!9^%J5otLGQsOWHH{Z*Xo@|ZQFs?<- z|4^`t$s@UQ=rUn@Ea+k)!IV~@Bo*v&4v`Ndh3?WZaf+Q$6IogSxTp&$)xO`wU{+u KPl-E z&sO*k1v?)slDW7c685Kr#s^|eX$6X@V2^W&tQ##f*C8v1y3N+(bL^fnekCl>u)rbs zo=oC-DzEe-uQ@{+8h|B6O3B@9?7%2LCFcfnroy(9Z@-59d LW{Pb2R+Wb@4MZ?f literal 0 HcmV?d00001 diff --git a/CabManagementSystem/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources b/CabManagementSystem/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources index d3538586f1f91b21d1e4e3c40e112f527d82511d..6aae9ba14ccc041fcedfafe5a01f62bb1ca88e7c 100644 GIT binary patch delta 133 zcmZ3^x}0@_f=qa7ih@^So`Ru)f}xR>v4xe1p@L^{h=P%Uk;&v#o`SJ~f{~$>k(rgDg@R{rh=P%Uk@4hSMh$K=3kyRN15 Draggable - + toolbarSeparator @@ -390,7 +390,7 @@ Draggable - + toolbarSeparator @@ -510,6 +510,7 @@ + @@ -589,7 +590,6 @@ - @@ -757,6 +757,10 @@ + + + + @@ -949,28 +953,28 @@ - + Spy - - - - + + + + - - - + + + - + - - + + - + @@ -1402,6 +1406,24 @@ View categoryTag:Other + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Other + glue @@ -2398,6 +2420,15 @@ + + + + + + + + + @@ -2409,7 +2440,7 @@ - + diff --git a/CabManagementSystem/.metadata/.plugins/org.eclipse.m2e.logback/0.log b/CabManagementSystem/.metadata/.plugins/org.eclipse.m2e.logback/0.log index f474cea..a445d5d 100644 --- a/CabManagementSystem/.metadata/.plugins/org.eclipse.m2e.logback/0.log +++ b/CabManagementSystem/.metadata/.plugins/org.eclipse.m2e.logback/0.log @@ -1 +1,2 @@ 2023-06-30 21:25:04,214 [Worker-1: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is out-of-date. Trying to update. +2024-01-10 12:36:59,935 [Worker-4: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is up-to-date. Trying to read. diff --git a/CabManagementSystem/.metadata/.plugins/org.eclipse.m2e.logback/logback.2.1.100.20230106-1511.xml b/CabManagementSystem/.metadata/.plugins/org.eclipse.m2e.logback/logback.2.1.100.20230106-1511.xml new file mode 100644 index 0000000..abdf1c7 --- /dev/null +++ b/CabManagementSystem/.metadata/.plugins/org.eclipse.m2e.logback/logback.2.1.100.20230106-1511.xml @@ -0,0 +1,41 @@ + + + + %date [%thread] %-5level %logger{35} - %msg%n + + + OFF + + + + + ${org.eclipse.m2e.log.dir}/0.log + + ${org.eclipse.m2e.log.dir}/%i.log + 1 + 10 + + + 10MB + + + %date [%thread] %-5level %logger{35} - %msg%n + + + + + + WARN + + + + + + + + + + + + + diff --git a/CabManagementSystem/.metadata/.plugins/org.eclipse.pde.core/.cache/clean-cache.properties b/CabManagementSystem/.metadata/.plugins/org.eclipse.pde.core/.cache/clean-cache.properties index db5bb25..0af8b00 100644 --- a/CabManagementSystem/.metadata/.plugins/org.eclipse.pde.core/.cache/clean-cache.properties +++ b/CabManagementSystem/.metadata/.plugins/org.eclipse.pde.core/.cache/clean-cache.properties @@ -1,2 +1,2 @@ #Cached timestamps -#Fri Jun 30 21:26:18 IST 2023 +#Wed Jan 10 12:38:41 IST 2024 diff --git a/CabManagementSystem/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml b/CabManagementSystem/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml index e452c8d..2f9ba3e 100644 --- a/CabManagementSystem/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml +++ b/CabManagementSystem/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml @@ -1,11 +1,44 @@
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
diff --git a/CabManagementSystem/.metadata/version.ini b/CabManagementSystem/.metadata/version.ini index 8dee503..754fb28 100644 --- a/CabManagementSystem/.metadata/version.ini +++ b/CabManagementSystem/.metadata/version.ini @@ -1,3 +1,3 @@ -#Fri Jun 30 21:24:44 IST 2023 +#Wed Jan 10 12:36:55 IST 2024 org.eclipse.core.runtime=2 -org.eclipse.platform=4.26.0.v20221123-1800 +org.eclipse.platform=4.27.0.v20230302-0300 diff --git a/CabManagementSystem/src/main/java/com/safar/config/AppConfig.java b/CabManagementSystem/src/main/java/com/safar/config/AppConfig.java index 2f29a59..8b30c82 100644 --- a/CabManagementSystem/src/main/java/com/safar/config/AppConfig.java +++ b/CabManagementSystem/src/main/java/com/safar/config/AppConfig.java @@ -58,6 +58,7 @@ public CorsConfiguration getCorsConfiguration(HttpServletRequest request) { .requestMatchers("/cabBooking/**","cabBooking","/WALLET/**").hasAnyRole("ADMIN","USER") .requestMatchers(HttpMethod.PATCH,"/users/**","/WALLET/**").hasAnyRole("ADMIN","USER") .requestMatchers("/WALLET/**").hasRole("USER") + .requestMatchers(HttpMethod.GET,"/WALLET/getWallet/**").hasRole("ADMIN") .anyRequest().authenticated(); }) .csrf(csrf -> csrf.disable()) diff --git a/CabManagementSystem/src/main/java/com/safar/controller/WalletController.java b/CabManagementSystem/src/main/java/com/safar/controller/WalletController.java index a79e50d..babc686 100644 --- a/CabManagementSystem/src/main/java/com/safar/controller/WalletController.java +++ b/CabManagementSystem/src/main/java/com/safar/controller/WalletController.java @@ -1,6 +1,7 @@ package com.safar.controller; import com.safar.entity.Users; +import com.safar.exceptions.UsersException; import com.safar.service.UserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -35,12 +36,18 @@ public class WalletController { /** * Adds money to a user's wallet. * - * @param auth The authentication object for the logged-in user. + * + * @param auth The authentication object for the logged-in user * @param amount The amount of money to add. + * @author Ankit choubey * @return The updated wallet. + * */ @PostMapping("/addMoney") public ResponseEntityaddMoneyToWallet(Authentication auth, @RequestParam("amount") Float amount){ + if(auth==null) + throw new UsersException("User not logged in"); + Users user = userService.getUserDetailsByEmail(auth.getName()); Wallet wallet = user.getWallet(); Wallet res= wService.addMoney(wallet.getWalletId(), amount); @@ -51,6 +58,7 @@ public class WalletController { * Changes the status of a wallet. * * @param auth The authentication object for the logged-in user. + * @author Ankit choubey * @return The updated wallet. */ @PatchMapping("/changeStatus") @@ -65,24 +73,26 @@ public ResponseEntity changeStatus(Authentication auth) { * Creates a wallet for a user. * * @param email The email of the user for whom to create the wallet. + * @author Ankit choubey * @return The created wallet. */ - @PostMapping("/createWallet/{email}") - public ResponseEntity createWallet(@PathVariable String email) { + @PostMapping("/createWallet") + public ResponseEntity createWallet(@RequestParam("email") String email) { Wallet res = wService.createWallet(email); return new ResponseEntity<>(res, HttpStatus.CREATED); } /** - * Retrieves a user's wallet. + * Retrieves a wallet details using its id. * - * @param auth The authentication object for the logged-in user. - * @return The user's wallet. + * @param wid Wallet id + * @author Ankit choubey + * @return The wallet details */ - @GetMapping("/getWallet") - public ResponseEntity getWallet(Authentication auth) { - Users user = userService.getUserDetailsByEmail(auth.getName()); - Wallet wallet = user.getWallet(); + @GetMapping("/getWallet/{wid}") + public ResponseEntity getWallet( @PathVariable("wid") Integer wid ) { + + Wallet wallet = wService.getWallet(wid); return new ResponseEntity<>(wallet, HttpStatus.ACCEPTED); } @@ -91,10 +101,11 @@ public ResponseEntity getWallet(Authentication auth) { * * @param auth The authentication object for the logged-in user. * @return The wallet details of the logged-in user. + * @author Ankit choubey */ @GetMapping("/WalletDetails") public ResponseEntity getLoggedUserWallet(Authentication auth) { - if (auth.getName() == null) + if (auth.getName() == "") throw new WalletException("User is not logged into the system"); Wallet res = wService.getLoggedUserWallet(auth.getName()); return new ResponseEntity<>(res, HttpStatus.ACCEPTED); diff --git a/CabManagementSystem/src/main/java/com/safar/service/serviceImpl/WalletServicesImpl.java b/CabManagementSystem/src/main/java/com/safar/service/serviceImpl/WalletServicesImpl.java index d092461..60e07e9 100644 --- a/CabManagementSystem/src/main/java/com/safar/service/serviceImpl/WalletServicesImpl.java +++ b/CabManagementSystem/src/main/java/com/safar/service/serviceImpl/WalletServicesImpl.java @@ -215,7 +215,7 @@ public Wallet getLoggedUserWallet(String email) { if(email==null) throw new UsersException("Invalid user details provided"); - Users user= urepo.findByEmail(email).orElseThrow(()->new UsersException(" No logged User not found")); + Users user= urepo.findByEmail(email).orElseThrow(()->new UsersException(" User not found OR You should logged in")); Wallet res= user.getWallet(); if(res==null) throw new WalletException("NO Wallet found "); diff --git a/CabManagementSystem/src/main/resources/application.properties b/CabManagementSystem/src/main/resources/application.properties index 6451658..3192594 100644 --- a/CabManagementSystem/src/main/resources/application.properties +++ b/CabManagementSystem/src/main/resources/application.properties @@ -5,7 +5,7 @@ server.port=8888 spring.datasource.url=jdbc:mysql://localhost:3306/safar spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.username=root -spring.datasource.password=Sushil8081 +spring.datasource.password=ankitchoubey9807 #ORM s/w specific properties diff --git a/CabManagementSystem/src/test/java/com/safar/controller/WalletControllerTest.java b/CabManagementSystem/src/test/java/com/safar/controller/WalletControllerTest.java new file mode 100644 index 0000000..cd89f47 --- /dev/null +++ b/CabManagementSystem/src/test/java/com/safar/controller/WalletControllerTest.java @@ -0,0 +1,128 @@ +package com.safar.controller; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.safar.entity.Users; +import com.safar.entity.Wallet; +import com.safar.entity.WalletStatus; +import com.safar.service.UserService; +import com.safar.service.WalletServices; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.MvcResult; +import org.springframework.test.web.servlet.RequestBuilder; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; + +import static org.mockito.ArgumentMatchers.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@WebMvcTest(controllers = WalletController.class) +@AutoConfigureMockMvc(addFilters=false) +public class WalletControllerTest { + + @Autowired + private MockMvc mockMvc; + + @MockBean + private WalletServices walletServices; + + @MockBean + private UserService userService; + + private Wallet requestWallet; + + private Wallet responseWallet; + + private Users user; + + private Authentication auth; + + @BeforeEach + public void init(){ + requestWallet = new Wallet(); + requestWallet.setBalance(0.0f); + requestWallet.setStatus(WalletStatus.Active); + + responseWallet= new Wallet(); + responseWallet.setWalletId(1); + responseWallet.setBalance(0.0f); + responseWallet.setStatus(WalletStatus.Active); + user= new Users(); + user.setWallet(responseWallet); + auth = new UsernamePasswordAuthenticationToken("testusername","testpassword"); + + } + + @Test + @DisplayName("Wallet can be created") + public void testCreateWallet_WhenValidEmailPassed_shouldReturnWalletEnity() throws Exception { + Mockito.when(walletServices.createWallet(anyString())).thenReturn(responseWallet); + RequestBuilder builder = MockMvcRequestBuilders.post("/WALLET/createWallet").param("email","ankit@gmail.com").contentType(MediaType.APPLICATION_JSON_VALUE); + + MvcResult mvcResult = mockMvc.perform(builder).andExpect(status().isCreated()).andReturn(); + + String responseBodyAsString = mvcResult.getResponse().getContentAsString(); + + Wallet resWallet= new ObjectMapper().readValue(responseBodyAsString,Wallet.class); + + Assertions.assertNotNull(resWallet.getWalletId(),"Created wallet should have a id"); + Assertions.assertEquals(responseWallet.getWalletId(),resWallet.getWalletId(),"Walled id should equal to 1"); + Mockito.verify(walletServices, Mockito.times(1)).createWallet(anyString()); + + + } + + + + @Test + @DisplayName("Money can be added to wallet") + public void testAddMoneyToWallet_WhenAmountPassed_ThenMoneyShouldBeAddedIntoWallet() throws Exception { + + + + Mockito.when(userService.getUserDetailsByEmail(auth.getName())).thenReturn(user); + responseWallet.setBalance(10.0f); + Mockito.when(walletServices.addMoney(anyInt(), anyFloat())).thenReturn(responseWallet); + + RequestBuilder requestBuilder = MockMvcRequestBuilders.post("/WALLET/addMoney") + .param("amount", "10") // remove double quotes + .principal(auth) + .contentType(MediaType.APPLICATION_JSON_VALUE); + + MvcResult mvcResult = mockMvc.perform(requestBuilder).andExpect(status().isAccepted()).andReturn(); + String responseBodyAsString = mvcResult.getResponse().getContentAsString(); + Wallet resWallet = new ObjectMapper().readValue(responseBodyAsString, Wallet.class); + + Assertions.assertNotNull(resWallet.getWalletId(), "wallet should have a id"); + Assertions.assertEquals(10.0f, resWallet.getBalance(), "Walled should have added balance"); + Mockito.verify(walletServices, Mockito.times(1)).addMoney(anyInt(), anyFloat()); + } + + @Test + @DisplayName("wallet status can be change") + public void testChangeStatus_WhenValidUserLoggedIn_thenWalletStatusCanBeChanged() throws Exception { + Mockito.when(userService.getUserDetailsByEmail(auth.getName())).thenReturn(user); + responseWallet.setStatus(WalletStatus.Inactive); + Mockito.when(walletServices.changeStatus(anyInt())).thenReturn(responseWallet); + RequestBuilder requestBuilder= MockMvcRequestBuilders.patch("/WALLET/changeStatus").principal(auth).contentType(MediaType.APPLICATION_JSON_VALUE); + MvcResult mvcResult= mockMvc.perform(requestBuilder).andExpect(status().isAccepted()).andReturn(); + String responseBodyAsString= mvcResult.getResponse().getContentAsString(); + Wallet resWallet= new ObjectMapper().readValue(responseBodyAsString,Wallet.class); + + Assertions.assertNotNull(resWallet.getWalletId(),"Wallet should have a id"); + Assertions.assertEquals(WalletStatus.Inactive,resWallet.getStatus(),"status should be Inactive"); + + } + +}