How to mock a POST request with json data using Mockito

I have the following unit test package mobi.grocerymonkey.groceryapp; import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.when; import static org.mockito.Mockito.mock; import com.google.appengine.tools.development.testing.LocalServiceTestHelper; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import java.io.PrintWriter; import java.io.StringWriter; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Unit tests for {@link HelloAppEngine}. */ @RunWith(JUnit4.class) public class GroceryServletTest { private…

Details

How to avoid excessive dataframe query

Consider there is spark job has multiple dataframe transitions val baseDF1 = spark.sql(s”select * from db.table1 where condition1=’blah'”) val baseDF2 = spark.sql(s”select * from db.table2 where condition2=’blah'”) val df3 = basedDF1.join(baseDF12, basedDF1(“col1”) <=> basedDF1(“col2”)) val df4 = df3.withcolumn(“col3”).withColumnRename(“col4”, “newcol4”) val df5 = df4.groupBy(“groupbycol”).agg(expr(“coalesce(first(col5, false))”)) val df6 = df5.withColumn(“level1”, col(“coalesce(first(col5, false))”)(0)) .withColumn(“level2”, col(“coalesce(first(col5, false))”)(1)) .withColumn(“level3”, col(“coalesce(first(col5,…

Details

EADDRINUSE on every port in Node/Express.js event after restart linux

I am running node with express.js over it on Linux. It was working but now when I start my server the followng error is displayed: Error: listen EADDRINUSE: address already in use 0.0.0.0:1223. Output: events.js:282 throw er; // Unhandled ‘error’ event ^ Error: listen EADDRINUSE: address already in use 0.0.0.0:1223 at Server.setupListenHandle [as _listen2] (net.js:1308:16)…

Details