Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6677593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:08:27+00:00 2026-05-26T04:08:27+00:00

I have plain Jar Project that reference by android application. Then, I have Functions.java

  • 0

I have plain Jar Project that reference by android application.
Then, I have Functions.java for my common functions which I want to create unit test class.

Here are the sample functions inside the Functions.java:

public static double getAltitudeBySensor(float atmosphericPressure) {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD
            && atmosphericPressure > 0d) {
        return SensorManager.getAltitude(SensorManager.PRESSURE_STANDARD_ATMOSPHERE, atmosphericPressure);
    }
    return 0d;
}

public static double toPixelX(double imageSize, android.location.Location upperLeft, android.location.Location lowerRight, android.location.Location target) {
    double hypotenuse = upperLeft.distanceTo(target);
    double bearing = upperLeft.bearingTo(target);
    double currentDistanceX = Math.sin(bearing * Math.PI / OneEightyDeg) * hypotenuse;
    //                           "percentage to mark the position"
    double totalHypotenuse = upperLeft.distanceTo(lowerRight);
    double totalDistanceX = totalHypotenuse * Math.sin(upperLeft.bearingTo(lowerRight) * Math.PI / OneEightyDeg);
    double currentPixelX = currentDistanceX / totalDistanceX * imageSize;

    return currentPixelX;
}

Any guidance on the right direction is appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:08:28+00:00Added an answer on May 26, 2026 at 4:08 am

    Both methods have dependencies on external code so will be difficult to unit test.

    If you really want to unit test just the logic then you’ll need to refactor so they depend on interfaces and then build mocks that implement those interfaces so you can pass in known data and test if you receive the appropriate output

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In an iPhone application, I have some plain C functions. Is it possible to
I have a JAVA project that updates a database. But I have to manually
I have a Java web application that has a 'disconnected' Java Swing desktop app.
I have an application which has a font stored within a jar file. It
I have an Android project which included a class with a file copy method.
I want to create a system UIBarButton, but I want it to have plain
Shame on me, but i have a plain asp iis6 server and they want
In an app I'm working on, I have a plain style UITableView that can
I have a truckload of xsd with plain SQL queries. I want to migrate
I have a hierarchical maven project, from which I am trying to build a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.