mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 14:53:59 +01:00 
			
		
		
		
	defined the key variable
This commit is contained in:
		
							parent
							
								
									6e929e3786
								
							
						
					
					
						commit
						860854a940
					
				
					 1 changed files with 11 additions and 7 deletions
				
			
		|  | @ -48,29 +48,33 @@ class JsonKvStoreTest { | ||||||
| 
 | 
 | ||||||
|     @Test |     @Test | ||||||
|     fun getJson() { |     fun getJson() { | ||||||
|         whenever(prefs.getString("key", null)).thenReturn(expected) |         val key = "key"  // Define the key variable | ||||||
| 
 | 
 | ||||||
|         val result = store.getJson("key", Person::class.java) |         whenever(prefs.getString(key, null)).thenReturn(expected) | ||||||
|  | 
 | ||||||
|  |         val result = store.getJson(key, Person::class.java) | ||||||
| 
 | 
 | ||||||
|         Assert.assertEquals(testData, result) |         Assert.assertEquals(testData, result) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Test |     @Test | ||||||
|     fun getJsonInTheFuture() { |     fun getJsonInTheFuture() { | ||||||
|         whenever(prefs.getString("key", null)).thenReturn(expected) |         val key = "key"  // Define the key variable | ||||||
|  |         whenever(prefs.getString(key, null)).thenReturn(expected) | ||||||
| 
 | 
 | ||||||
|         val resultOne: Person? = store.getJson("key") |         val resultOne: Person? = store.getJson(key) | ||||||
|         Assert.assertEquals(testData, resultOne) |         Assert.assertEquals(testData, resultOne) | ||||||
| 
 | 
 | ||||||
|         val resultTwo = store.getJson<Person?>("key") |         val resultTwo = store.getJson<Person?>(key) | ||||||
|         Assert.assertEquals(testData, resultTwo) |         Assert.assertEquals(testData, resultTwo) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Test |     @Test | ||||||
|     fun getJsonHandlesMalformedJson() { |     fun getJsonHandlesMalformedJson() { | ||||||
|         whenever(prefs.getString("key", null)).thenReturn("junk") |         val key = "key"  // Define the key variable | ||||||
|  |         whenever(prefs.getString(key, null)).thenReturn("junk") | ||||||
| 
 | 
 | ||||||
|         val result = store.getJson("key", Person::class.java) |         val result = store.getJson(key, Person::class.java) | ||||||
| 
 | 
 | ||||||
|         Assert.assertNull(result) |         Assert.assertNull(result) | ||||||
|     } |     } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 sonalyadav
						sonalyadav