* Also testing the hash results are consistent
*/
public void testFrameworkUid() throws Exception {
final AuraJavascriptGroup jsGroup = mock(AuraJavascriptGroup.class);
Hash jsHash = mock(Hash.class);
when(jsGroup.isStale()).thenReturn(false);
when(jsGroup.getGroupHash()).thenReturn(jsHash);
final AuraResourcesHashingGroup resourcesGroup = mock(AuraResourcesHashingGroup.class);
Hash resourcesHash = mock(Hash.class);
when(resourcesGroup.isStale()).thenReturn(false);
when(resourcesGroup.getGroupHash()).thenReturn(resourcesHash);
ConfigAdapterImpl configAdapter = new ConfigAdapterImpl() {
@Override
protected AuraJavascriptGroup newAuraJavascriptGroup() throws IOException {
return jsGroup;
}
@Override
protected FileGroup newAuraResourcesHashingGroup() throws IOException {
return resourcesGroup;
}
};
ConfigAdapterImpl spy = Mockito.spy(configAdapter);
when(jsHash.toString()).thenReturn("jsGroup");
when(resourcesHash.toString()).thenReturn("resourcesGroup");
String uid = spy.getAuraFrameworkNonce();
verify(spy, Mockito.times(1)).makeHash(anyString(), anyString());
assertEquals("Framework uid is not correct", "9YifBh-oLwXkDGW3d3qyDQ", uid);
reset(spy);
uid = spy.getAuraFrameworkNonce();
// test that makeHash is not called because jsHash and resourcesHash has not changed
verify(spy, Mockito.never()).makeHash(anyString(), anyString());
assertEquals("Framework uid is not correct", "9YifBh-oLwXkDGW3d3qyDQ", uid);
// change js hash, verify changes framework nonce
when(jsHash.toString()).thenReturn("MocKitYMuCK");
reset(spy);
uid = spy.getAuraFrameworkNonce();
verify(spy, Mockito.times(1)).makeHash(anyString(), anyString());
assertEquals("Framework uid is not correct", "ltz-V8xGPGhXbOiTtfSApQ", uid);
// change resource hash, verify changes framework nonce
when(resourcesHash.toString()).thenReturn("MuCkiTyMocK");
reset(spy);
uid = spy.getAuraFrameworkNonce();
verify(spy, Mockito.times(1)).makeHash(anyString(), anyString());
assertEquals("Framework uid is not correct", uid, "BJTaoiCDxoAF4Wbh0iC9lA");