Business, Code, JavaEE, SOA, Technical, WebServices

Current Technology Research

Languages – used to solve problems that work with user interaction and machine development.

Kotlin for Java and Android.

Swift for IOS and Mac.
Cloud Technologies and Platforms – Infrastructure, functions and platforms that provide integrated solutions for systems and applications high availability and deployments.

Amazon Web Services (AWS).

Google Firebase

Understanding Domain Driven Design – is an approach to software development for complex needs by connecting the implementation to an evolving model.

http://en.wikipedia.org/wiki/Domain-driven_design

http://dddsample.sourceforge.net/

http://www.domainlanguage.com/


Reactive Programming
– is a programming paradigm oriented around data flows and the propagation of change.

http://en.wikipedia.org/wiki/Reactive_programming

http://news.dice.com/2014/01/13/how-is-reactive-different-from-procedural-programming/

https://www.youtube.com/watch?v=jIsxcXBWthI


Concurrency in Java
– is a form of computing in which several computations are executing during overlapping time periods –concurrently – instead of sequentially (one completing before the next starts). This is a property of a system – this may be an individual program, a computer, or a network – and there is a separate execution point or “thread of control” for each computation (“process”).

http://en.wikipedia.org/wiki/Concurrent_programming

http://en.wikipedia.org/wiki/Concurrency_in_java

http://tutorials.jenkov.com/java-concurrency/index.html

Hexagonal Architecture – Allow an application to equally be driven by users, programs, automated test or batch scripts, and to be developed and tested in isolation from its eventual run-time devices and databases.

As events arrive from the outside world at a port, a technology-specific adapter converts it into a usable procedure call or message and passes it to the application. The application is blissfully ignorant of the nature of the input device. When the application has something to send out, it sends it out through a port to an adapter, which creates the appropriate signals needed by the receiving technology (human or automated). The application has a semantically sound interaction with the adapters on all sides of it, without actually knowing the nature of the things on the other side of the adapters.

http://alistair.cockburn.us/Hexagonal+architecture

Software Company

http://asp-software.org/www/misv_resources/marketing-articles/how-to-make-a-million-dollars-in-software/

 

Code

Regular Expression Java – Mock Test Answers

The following string (inputs) is used to simulate a clients answers to five questions. The format is the question number followed by a delimiter and the alphabetic choice for that question.

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class CoreJavaApplicationTests {
 final String inputs = "1:A, 2:B, 3:B, 4:A, 5:C";
 final String pattern = "[0-9]:[a-zA-Z],*";

 @Test
 public void parseAllSolution() {
 Matcher matchAll = Pattern.compile(pattern).matcher(inputs);
 printSections(matchAll);
 }

 private void printSections(Matcher matcher) {
 while (matcher.find()) {
 String item = matcher.group();

 Integer id = Integer.valueOf(item.replaceAll(patternSuffix,"").replaceAll(",",""));
 System.out.printf("\n PREFIX %s%n", id);

 String meta = item.replaceAll(patternPrefix,"").replaceAll(",","");
 System.out.printf("SUFFIX %s%n", meta);

 disp(id,meta);
 }

 }

 private void disp(Integer question, String response) {
 System.out.printf("ID: %d, RESP: %s%n", question, response);

 baselist.forEach(item -> {
 if (item.getId() == question && item.getResponse().equalsIgnoreCase(response)) {
 System.out.printf("Choice: Question - %d, Answer - %s, Data - %s%n", question, item.getResponse(), item.getDescriptor());
 }
 });
 }
}

 

Code, JavaEE, SOA, Technical, WebServices

Read Remote File Contents

@Test
public void formatOutput() {
    final String routerJS =
            "static/master/router.js";
    readRemoteFileContents(routerJS);
}

private void readRemoteFileContents(final String fileToRead) {
    HttpURLConnection connection = null;
    try {
        connection = (HttpURLConnection)githubURL(fileToRead).openConnection();
    } catch (IOException e) {
        e.printStackTrace();
    }

    Scanner scanner = null;
    try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
        scanner = new Scanner(
                new StringReader(
                        reader.lines().collect(
                                Collectors.joining(System.getProperty("line.separator")))))
        .useDelimiter(System.getProperty("line.separator"));

        while(scanner.hasNext()) {
            System.out.printf("%s%n", scanner.next());
        }
    } catch (IOException e) {

    } finally {
        if (scanner != null) scanner.close();
        if (connection != null) connection.disconnect();
    }

}

private URL githubURL(final String fileToRead) throws MalformedURLException {
    final String baseGitHubFiles = "https://raw.githubusercontent.com/enterprisesaas/";
    final StringBuilder url = new StringBuilder(baseGitHubFiles).append(fileToRead);
    return new URL(url.toString());
}
Code, JavaEE, Technical

View Zip File Contents

@Test
public void viewCompressedStreamContents() {
    final String basePath = "/Server/path/";
    final String zip = basePath + "favicons.zip";

    try (InputStream zipStream = Files.newInputStream(Paths.get(zip))) {
        ZipInputStream buffered = new ZipInputStream(zipStream);
        ZipEntry entry;
        while ((entry = buffered.getNextEntry()) != null) {
            System.out.println(entry.toString());
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Code

Mock Utility Class

Doing some exploration, I created the following Mock class with a mix of methods for filtering using different methods. The client simply invokes the method in a static way.


public final class Mock {
private static String mockFileBaseLocation = System.getProperty("user.dir");
private static String mockFileResourcesLocation = "src\\test\\resources";

public Mock() {
}

public static Map<String, Object> getEachXmlFileAsString(Map<String, Object> data) {
return iterateAndConvert(data).get();
}

public static String getXmlAsString(final String whichFileFromTheMockDatabase) {
return readContentsOfFileIntoString(
Mock.buildFullPathToXmlTestFile(whichFileFromTheMockDatabase));
}

public static Observable<Map<String, Object>> map(Map<String, Object> data) {
return Observable.from(data).map(Mock::transformMap);
}

public static Observable<Map<String, Object>> filter(Map<String, Object> data, String removeKey) {
return Observable.from(data).filter((entry) -> isItemInDataThenRemove(entry, removeKey));
}

public static Observable<Map<String, Object>> preserve(Map<String, Object> data, String preserveKey) {
return Observable.from(data).filter((entry) -> isItemInDataThenPreserveAndRemoveEverythingElse(data, preserveKey));
}

private static Map<String, Object> iterateAndConvertValueXmlToString(Map<String, Object> data) {
Map<String, Object> returnMap = new HashMap<>();
for (Map.Entry<String,Object> entry : data.entrySet()) {
returnMap.put(entry.getKey(), getXmlAsString((String)entry.getValue()));
}
return returnMap;
}

private static boolean isItemInDataThenRemove(Map<String, Object> data, String removeKey) {
data.entrySet().stream().filter(entry ->
entry.getKey().equalsIgnoreCase(removeKey)).forEach(entry -> {
data.remove(entry.getKey());
});
return true;
}

private static boolean isItemInDataThenPreserveAndRemoveEverythingElse(Map<String, Object> data, String preserveKey) {
data.entrySet().stream().filter(entry -> !entry.getKey().equalsIgnoreCase(preserveKey)).forEach(entry -> {
System.out.printf("Found element that is not to be preserved %s, removing. %n", entry.getKey());
data.remove(entry.getKey());
});

return data.get(preserveKey) != null;
}

private static Supplier<Map<String, Object>> iterateAndConvert(Map<String, Object> data) {
Map<String, Object> returnMap = new HashMap<>();
data.entrySet().forEach((entry) ->
returnMap.put(entry.getKey(), getXmlAsString((String)entry.getValue())));
return () -> returnMap;
}

private static Map<String, Object> transformMap(Map<String, Object> data) {
Map<String, Object> returnMap = new HashMap<>();
data.entrySet().forEach((entry) ->
returnMap.put(entry.getKey(), getXmlAsString((String)entry.getValue())));
return returnMap;
}

private static String buildFullPathToXmlTestFile(final String xmlFileName) {
return String.format("%s\\%s\\%s",
Mock.getMockFileBaseLocation(), Mock.getMockFileResourcesLocation(),
xmlFileName);
}

private static String getMockFileBaseLocation() {
return mockFileBaseLocation;
}

private static String getMockFileResourcesLocation() {
return mockFileResourcesLocation;
}

private static String readContentsOfFileIntoString(final String whichFileFromTheMockDatabase) {
String contentToReturn = "";

try (Scanner scanner = new Scanner(new File(whichFileFromTheMockDatabase))) {
scanner.useDelimiter("\\A");
contentToReturn = scanner.next();
} catch (IOException ioe) {
System.out.printf("IOException occured: %s%n", ioe.toString());
ioe.printStackTrace();
}

return contentToReturn;
}

private static InputStream openXmlFile(String fileClassPath) {
File temp = new File(fileClassPath);

try (InputStream inputStream = new FileInputStream(temp)) {
System.out.printf("Returning openXmlFile: %s%n", temp.getAbsolutePath());
return inputStream;
} catch (IOException ioe) {
System.out.printf("IOException occured: %s%n", ioe.toString());
ioe.printStackTrace();
}

return null;
}

private static File createFileFromInputStream(String fileNameAndPath, InputStream inputStream) {
File outFile = new File(fileNameAndPath);

try (OutputStream outputStream = new FileOutputStream(outFile)) {
int readBytes = 0;
byte[] byteBuffer = new byte[2048];
while ((readBytes = inputStream.read(byteBuffer)) != -1) {
outputStream.write(byteBuffer, 0, readBytes);
}
} catch (IOException ioe) {
System.out.printf("IOException occured: %s%n", ioe.toString());
ioe.printStackTrace();
} finally {
if (inputStream != null) {
try { inputStream.close(); } catch (IOException ioe) {
System.out.printf("IOException occured: %s%n", ioe.toString());
ioe.printStackTrace();
}
}
}

return outFile;
}
}